aboutsummaryrefslogtreecommitdiffstats
path: root/ext/psych/lib/psych/visitors/to_ruby.rb
diff options
context:
space:
mode:
Diffstat (limited to 'ext/psych/lib/psych/visitors/to_ruby.rb')
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index 2790cdeb3d..56c970002c 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -219,10 +219,16 @@ module Psych
end
def init_with o, h, node
+ c = Psych::Coder.new(node.tag)
+ c.map = h
+
if o.respond_to?(:init_with)
- c = Psych::Coder.new(node.tag)
- c.map = h
o.init_with c
+ elsif o.respond_to?(:yaml_initialize)
+ if $VERBOSE
+ "Implementing #{o.class}#yaml_initialize is deprecated, please implement \"init_with(coder)\""
+ end
+ o.yaml_initialize c.tag, c.map
else
h.each { |k,v| o.instance_variable_set(:"@#{k}", v) }
end