Project

General

Profile

Feature #12960 » 0004-feat-psych-add-hook-points-for-mapping-like-object.patch

kwatch (makoto kuwata), 11/19/2016 03:21 AM

View differences:

ext/psych/lib/psych/visitors/to_ruby.rb
when '!omap', 'tag:yaml.org,2002:omap'
map = register(o, Psych::Omap.new)
o.children.each { |a|
map[accept(a.children.first)] = accept a.children.last
map[accept_key(a.children.first)] = accept_value a.children.last
}
map
when /^!(?:seq|ruby\/array):(.*)$/
......
members = {}
struct_members = s.members.map { |x| class_loader.symbolize x }
o.children.each_slice(2) do |k,v|
member = accept(k)
value = accept(v)
member = accept_key(k)
value = accept_value(v)
if struct_members.include?(class_loader.symbolize(member))
s.send("#{member}=", value)
else
......
string = nil
o.children.each_slice(2) do |k,v|
key = accept k
value = accept v
key = accept_key k
value = accept_value v
if key == 'str'
if klass
......
set = class_loader.psych_set.new
@st[o.anchor] = set if o.anchor
o.children.each_slice(2) do |k,v|
set[accept(k)] = accept(v)
set[accept_key(k)] = accept_value(v)
end
set
......
revive_hash hash, value
when 'ivars'
value.children.each_slice(2) do |k,v|
hash.instance_variable_set accept(k), accept(v)
hash.instance_variable_set accept_key(k), accept_value(v)
end
end
end
......
when '!omap', 'tag:yaml.org,2002:omap'
map = register(o, class_loader.psych_omap.new)
o.children.each_slice(2) do |l,r|
map[accept(l)] = accept r
map[accept_key(l)] = accept_value r
end
map
(4-4/10)