mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/ostruct.rb (OpenStruct#delete): Use the converted argument.
Patch by Kenichi Kamiya. [Fixes GH-383] * test/ostruct/test_ostruct.rb: Added tests for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b9e18abe4a
commit
99d5d90f2f
2 changed files with 11 additions and 1 deletions
|
@ -220,7 +220,7 @@ class OpenStruct
|
|||
#
|
||||
def delete_field(name)
|
||||
sym = name.to_sym
|
||||
singleton_class.__send__(:remove_method, sym, "#{name}=")
|
||||
singleton_class.__send__(:remove_method, sym, "#{sym}=")
|
||||
@table.delete sym
|
||||
end
|
||||
|
||||
|
|
|
@ -68,6 +68,16 @@ class TC_OpenStruct < Test::Unit::TestCase
|
|||
assert_not_respond_to(o, :a, bug)
|
||||
assert_not_respond_to(o, :a=, bug)
|
||||
assert_equal(a, 'a')
|
||||
s = Object.new
|
||||
def s.to_sym
|
||||
:foo
|
||||
end
|
||||
o[s] = true
|
||||
assert_respond_to(o, :foo)
|
||||
assert_respond_to(o, :foo=)
|
||||
o.delete_field s
|
||||
assert_not_respond_to(o, :foo)
|
||||
assert_not_respond_to(o, :foo=)
|
||||
end
|
||||
|
||||
def test_setter
|
||||
|
|
Loading…
Add table
Reference in a new issue