summaryrefslogtreecommitdiff
path: root/ext/psych/lib/psych/visitors/to_ruby.rb
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-08 22:00:54 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-08 22:00:54 +0000
commit8c08c8298a03a01629a478b74abfd57d7f35cb05 (patch)
treebe53d22fe5df98d9a4405d61a496d1ef0d9d8c0c /ext/psych/lib/psych/visitors/to_ruby.rb
parent2b2f9b75febc5d7a9b1384f84ee161a16af9f83d (diff)
* ext/psych/lib/psych/visitors/to_ruby.rb: revive hashes with ivars
* ext/psych/lib/psych/visitors/yaml_tree.rb: dump hashes with ivars. Fixes github.com/psych/issues/43 * test/psych/test_hash.rb: test for change git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/psych/lib/psych/visitors/to_ruby.rb')
-rw-r--r--ext/psych/lib/psych/visitors/to_ruby.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb
index e696ebd4ff..adf38a21e8 100644
--- a/ext/psych/lib/psych/visitors/to_ruby.rb
+++ b/ext/psych/lib/psych/visitors/to_ruby.rb
@@ -261,6 +261,20 @@ module Psych
end
set
+ when /^!ruby\/hash-with-ivars(?::(.*))?$/
+ hash = $1 ? resolve_class($1).new : {}
+ o.children.each_slice(2) do |key, value|
+ case key.value
+ when 'elements'
+ revive_hash hash, value
+ when 'ivars'
+ value.children.each_slice(2) do |k,v|
+ hash.instance_variable_set accept(k), accept(v)
+ end
+ end
+ end
+ hash
+
when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/
revive_hash register(o, resolve_class($1).new), o