mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
ostruct.rb: deferred accessors
* lib/ostruct.rb (freeze): define deferred accessors before freezing to get rid of an error when just reading frozen OpenStruct. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2f2a5c3ae9
commit
6e5967e2ae
2 changed files with 11 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
|||
Fri Jan 1 03:26:44 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/ostruct.rb (freeze): define deferred accessors before
|
||||
freezing to get rid of an error when just reading frozen
|
||||
OpenStruct.
|
||||
|
||||
Thu Dec 31 14:36:45 2015 Marc-Andre Lafortune <ruby-core@marc-andre.ca>
|
||||
|
||||
* lib/ostruct.rb: Fix new_ostruct_member to correctly avoid
|
||||
|
|
|
@ -176,6 +176,11 @@ class OpenStruct
|
|||
end
|
||||
protected :new_ostruct_member
|
||||
|
||||
def freeze
|
||||
@table.each_key {|key| new_ostruct_member(key)}
|
||||
super
|
||||
end
|
||||
|
||||
def respond_to_missing?(mid, include_private = false)
|
||||
mname = mid.to_s.chomp("=").to_sym
|
||||
@table.key?(mname) || super
|
||||
|
|
Loading…
Reference in a new issue