diff --git a/ChangeLog b/ChangeLog index 28621c3d18..8d9da44de1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Fri Jan 1 03:26:44 2016 Nobuyoshi Nakada + + * 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 * lib/ostruct.rb: Fix new_ostruct_member to correctly avoid 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