Add some comments and expand some method documentation

This commit is contained in:
Chris Roberts 2022-04-13 15:11:49 -07:00 committed by Paul Hinze
parent 46efcb8af8
commit 9ab74271cf
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
2 changed files with 22 additions and 0 deletions

View File

@ -281,6 +281,18 @@ module VagrantPlugins
# applied. After the given block is executed, the value
# vertices will have their original weights re-applied.
#
# Since value vertices are identified by type, only
# one value of any type may exist in the graph. However,
# if the value is named, then multiple values of the same
# type may exist in the graph. For instance, with named
# values two strings could be provided, one named "local_path"
# and another named "remote_path". If a mapper function is
# only interested in the value of the "remote_path", it
# can include that name within its input definition. Then
# this method can be used to prefer the name string argument
# "remote_path" over the "local_path" named argument, or
# just a regular string value.
#
# @param vertex [Vertex] source vertex
# @param graph [Graph] graph to modify
# @yieldparam [Graph] modified graph (passed instance, not a copy)

View File

@ -43,19 +43,29 @@ module VagrantPlugins
value
end
# Determine if provided vertex is equivalent
#
# @param [Vertex]
# @return [Boolean]
def ==(v)
v.hash_code == hash_code
end
alias_method :eql?, :==
# Generate a hash for the given vertex. This is used
# to uniquely identify a vertex within a Hash.
#
# @return [Integer]
def hash
hash_code.to_s.chars.map(&:ord).sum.hash
end
# @return [String]
def to_s
"<Vertex value=#{value} hash=#{hash_code}>"
end
# @return [String]
def inspect
"<#{self.class.name} value=#{value} hash=#{hash_code}>"
end