summaryrefslogtreecommitdiff
path: root/lib/psych/visitors/yaml_tree.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-02-06 10:51:10 +0200
committerAaron Patterson <aaron.patterson@gmail.com>2015-02-06 10:51:10 +0200
commit43fa4aa38492c80080efa61aa4b7bee422792bc7 (patch)
tree3157c1ca1c1adf188f22c883ae6063f206fb3702 /lib/psych/visitors/yaml_tree.rb
parent6a191f45986a0ace06b743145364e6e66da46b9b (diff)
downloadpsych-43fa4aa38492c80080efa61aa4b7bee422792bc7.zip
* ext/psych/lib/psych/visitors/yaml_tree.rb: register nodes when
dumping objects with custom coders. [ruby-core:66215] [Bug #10496] * test/psych/test_coder.rb: test for fix
Diffstat (limited to 'lib/psych/visitors/yaml_tree.rb')
-rw-r--r--lib/psych/visitors/yaml_tree.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/psych/visitors/yaml_tree.rb b/lib/psych/visitors/yaml_tree.rb
index 8841cb0..e13fd77 100644
--- a/lib/psych/visitors/yaml_tree.rb
+++ b/lib/psych/visitors/yaml_tree.rb
@@ -21,6 +21,7 @@ module Psych
end
def register target, node
+ return unless target.respond_to? :object_id
@targets << target
@obj_to_node[target.object_id] = node
end
@@ -566,10 +567,10 @@ module Psych
c = Psych::Coder.new(tag)
o.encode_with(c)
- emit_coder c
+ emit_coder c, o
end
- def emit_coder c
+ def emit_coder c, o
case c.type
when :scalar
@emitter.scalar c.scalar, nil, c.tag, c.tag.nil?, false, Nodes::Scalar::ANY
@@ -580,7 +581,7 @@ module Psych
end
@emitter.end_sequence
when :map
- @emitter.start_mapping nil, c.tag, c.implicit, c.style
+ register o, @emitter.start_mapping(nil, c.tag, c.implicit, c.style)
c.map.each do |k,v|
accept k
accept v