mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/psych/lib/psych/deprecated.rb: adding deprecated object_maker
method, * test/psych/test_deprecated.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ad3c1061a7
commit
430e0ce491
2 changed files with 14 additions and 0 deletions
|
@ -66,6 +66,13 @@ module Psych
|
|||
end if name
|
||||
[type, reference]
|
||||
end
|
||||
|
||||
def self.object_maker klass, hash
|
||||
warn "#{caller[0]}: object_maker is deprecated" if $VERBOSE
|
||||
klass.allocate.tap do |obj|
|
||||
hash.each { |k,v| obj.instance_variable_set(:"@#{k}", v) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Object
|
||||
|
|
|
@ -199,5 +199,12 @@ module Psych
|
|||
assert_equal 'int', things.first
|
||||
assert_equal Object, things.last
|
||||
end
|
||||
|
||||
def test_object_maker
|
||||
thing = Psych.object_maker(Object, { 'a' => 'b', 'c' => 'd' })
|
||||
assert_instance_of(Object, thing)
|
||||
assert_equal 'b', thing.instance_variable_get(:@a)
|
||||
assert_equal 'd', thing.instance_variable_get(:@c)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue