ostruct.rb: fix NameError
* lib/ostruct.rb (delete_field): do not raise NameError for existing keys. [Fix GH-1033] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
690f2c7230
commit
b1cfb98e9e
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Sun Sep 27 08:16:35 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/ostruct.rb (delete_field): do not raise NameError for
|
||||||
|
existing keys. [Fix GH-1033]
|
||||||
|
|
||||||
|
Sun Sep 27 08:16:20 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* lib/ostruct.rb (delete_field): do not raise NameError for
|
||||||
|
existing keys. [Fix GH-1033]
|
||||||
|
|
||||||
Sun Sep 27 00:34:31 2015 Zachary Scott <zzak@ruby-lang.org>
|
Sun Sep 27 00:34:31 2015 Zachary Scott <zzak@ruby-lang.org>
|
||||||
|
|
||||||
* lib/ostruct.rb: Move method definitions for getter/setter to be lazy
|
* lib/ostruct.rb: Move method definitions for getter/setter to be lazy
|
||||||
|
@ -220,8 +220,13 @@ class OpenStruct
|
|||||||
#
|
#
|
||||||
def delete_field(name)
|
def delete_field(name)
|
||||||
sym = name.to_sym
|
sym = name.to_sym
|
||||||
|
begin
|
||||||
singleton_class.__send__(:remove_method, sym, "#{sym}=")
|
singleton_class.__send__(:remove_method, sym, "#{sym}=")
|
||||||
@table.delete sym
|
rescue NameError
|
||||||
|
end
|
||||||
|
@table.delete(sym) do
|
||||||
|
raise NameError.new("no field `#{sym}' in #{self}", sym)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
InspectKey = :__inspect_key__ # :nodoc:
|
InspectKey = :__inspect_key__ # :nodoc:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user