aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ostruct.rb
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-01 10:30:48 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-04-01 10:30:48 +0000
commit23924cfa397e3b2151118314b535fe90a3db85a7 (patch)
tree2e04ecb4748c221740187fd82f583ac23c084ee4 /lib/ostruct.rb
parentbe02a463922fd4d0a24327b8d8bb4d0001413770 (diff)
downloadruby-23924cfa397e3b2151118314b535fe90a3db85a7.tar.gz
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
Diffstat (limited to 'lib/ostruct.rb')
-rw-r--r--lib/ostruct.rb8
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: