method
revive_hash
v2_6_3 -
Show latest stable
- Class:
Psych::Visitors::ToRuby
revive_hash(hash, o)private
No documentation available.
# File ext/psych/lib/psych/visitors/to_ruby.rb, line 335
def revive_hash hash, o
o.children.each_slice(2) { |k,v|
key = accept(k)
val = accept(v)
if key == SHOVEL && k.tag != "tag:yaml.org,2002:str"
case v
when Nodes::Alias, Nodes::Mapping
begin
hash.merge! val
rescue TypeError
hash[key] = val
end
when Nodes::Sequence
begin
h = {}
val.reverse_each do |value|
h.merge! value
end
hash.merge! h
rescue TypeError
hash[key] = val
end
else
hash[key] = val
end
else
hash[key] = val
end
}
hash
end