Project

General

Profile

Bug #13358 ยป 0001-ostruct.rb-improve-fix-for-OpenStruct.allocate-respo.patch

Proposed fix for OpenStruct#respond_to_missing? - Eregon (Benoit Daloze), 03/28/2017 08:41 AM

View differences:

lib/ostruct.rb
# 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
......
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:
    (1-1/1)