diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-01 10:30:48 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-04-01 10:30:48 +0000 |
commit | a6456054aeb3ac859fd3f43b123b25673c266aa0 (patch) | |
tree | 2e04ecb4748c221740187fd82f583ac23c084ee4 | |
parent | 8dfd1e71fc99cff0d303e6c21270bc9b03c096a5 (diff) |
ostruct.rb: improve fix for OpenStruct.allocate + #respond_to?
* lib/ostruct.rb (OpenStruct#respond_to_missing?): this makes
OpenStruct#respond_to? works on any OpenStruct instance,
just like Kernel#respond_to? does, without workarounds.
[ruby-core:80292] [Bug #13358]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | lib/ostruct.rb | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 25ccac8dfa..2edb2edeb4 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -73,12 +73,6 @@ # of these properties compared to using a Hash or a Struct. # class OpenStruct - class << self # :nodoc: - def allocate - (x = super).instance_variable_set(:@table, {}) - x - end - end # # Creates a new OpenStruct object. By default, the resulting OpenStruct @@ -198,7 +192,7 @@ class OpenStruct def respond_to_missing?(mid, include_private = false) # :nodoc: mname = mid.to_s.chomp("=").to_sym - @table.key?(mname) || super + @table&.key?(mname) || super end def method_missing(mid, *args) # :nodoc: |