diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-31 18:26:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-31 18:26:46 +0000 |
commit | 3a23d2ad7b37a967dfdfcdd2b91009f6ec95b65a (patch) | |
tree | 3ff7a664e08ac830d8aa46674cef446ddb1e647e /lib | |
parent | b8ef3bcddbf0fc48902ce3fabd4408c45c3fe996 (diff) | |
download | ruby-3a23d2ad7b37a967dfdfcdd2b91009f6ec95b65a.tar.gz |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ostruct.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/ostruct.rb b/lib/ostruct.rb index e5b69608ad..17efcdc8d3 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -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 |