summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-23 08:39:46 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-23 08:39:46 +0000
commit7867dbdd1c3d40bbe897dd957ea1326ed3b3fcb1 (patch)
tree2a128c9fc5721c08475c536eaf5c587a65857e66 /lib
parent524e628fd33511e37d8c9de0bb43e9ea2e68376c (diff)
merge revision(s) 58077,58229: [Backport #13358]
ostruct.rb: fix OpenStruct.allocate * lib/ostruct.rb (OpenStruct.allocate): initialize an instance variable directly, without calling `intialize` method which may be overridden in a subclass. [ruby-core:80292] [Bug #13358] 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/branches/ruby_2_4@59407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/ostruct.rb5
1 files changed, 1 insertions, 4 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb
index 417ecf62b3..1d42321b66 100644
--- a/lib/ostruct.rb
+++ b/lib/ostruct.rb
@@ -71,9 +71,6 @@
# of these properties compared to using a Hash or a Struct.
#
class OpenStruct
- class << self # :nodoc:
- alias allocate new
- end
#
# Creates a new OpenStruct object. By default, the resulting OpenStruct
@@ -191,7 +188,7 @@ class OpenStruct
def respond_to_missing?(mid, include_private = false)
mname = mid.to_s.chomp("=").to_sym
- @table.key?(mname) || super
+ @table&.key?(mname) || super
end
def method_missing(mid, *args) # :nodoc: