diff options
-rw-r--r-- | lib/psych/visitors/yaml_tree.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb index 57d23e2..ba0307b 100644 --- a/lib/psych/visitors/yaml_tree.rb +++ b/lib/psych/visitors/yaml_tree.rb @@ -15,13 +15,19 @@ module Psych target.class.ancestors.each do |klass| next unless klass.name method_name = :"visit_#{klass.name.split('::').join('_')}" - if respond_to?(method_name) - return send(method_name, target) - end + return send(method_name, target) if respond_to?(method_name) end raise TypeError, "Can't dump #{target.class}" end + def visit_Psych_Omap o + @stack.push append Nodes::Sequence.new(nil, '!omap', false) + o.each do |k,v| + accept k => v + end + @stack.pop + end + def visit_Object o klass = o.class == Object ? nil : o.class.name tag = ['!ruby/object', klass].compact.join(':') |