Bug #13358 ยป 0001-ostruct.rb-improve-fix-for-OpenStruct.allocate-respo.patch
| 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: | ||