From 90e20ea51532ad799abb648ab26376cd22268b2d Mon Sep 17 00:00:00 2001 From: kwatch Date: Sat, 19 Nov 2016 09:11:49 +0900 Subject: [PATCH 4/9] feat(psych): add hook points for mapping-like object --- ext/psych/lib/psych/visitors/to_ruby.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index 9eb11bf..cebafee 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -142,7 +142,7 @@ def visit_Psych_Nodes_Sequence o 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):(.*)$/ @@ -171,8 +171,8 @@ def visit_Psych_Nodes_Mapping o 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 @@ -215,8 +215,8 @@ def visit_Psych_Nodes_Mapping o 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 @@ -258,7 +258,7 @@ def visit_Psych_Nodes_Mapping o 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 @@ -271,7 +271,7 @@ def visit_Psych_Nodes_Mapping o 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 @@ -283,7 +283,7 @@ def visit_Psych_Nodes_Mapping o 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 -- 2.9.3 (Apple Git-75)