Bug #1219
closedostruct freeze still not stable
Description
=begin
Freezing an ostruct still does not inhibit modification as can be seen in the attached test file and in the following example
o = OpenStruct::new :a => 42
OpenStruct.module_eval do def frozen?; nil end end
o.freeze
o.a = 1764
forwarding freeze to the table or a proxy object that has to change on any update seems necessary. Idea Joël VanderWerf!
=end
Files
Updated by RobertDober (Robert Dober) almost 16 years ago
=begin
Forget this patch it is a pain, and way to complicated. Your approach was fine, all we have to do is the following:
class OpenStruct
def freeze
@frozen ||= true
super
end
end
and now, in the write access method you have so nicely refactored, just check for @frozen instead of frozen?.
Cheers
Robert
=end
Updated by nobu (Nobuyoshi Nakada) almost 16 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r22652.
=end
Updated by RobertDober (Robert Dober) almost 16 years ago
=begin
Thank you, very nice solution.
On Fri, Feb 27, 2009 at 6:26 AM, Nobuyoshi Nakada redmine@ruby-lang.org wrote:
Issue #1219 has been updated by Nobuyoshi Nakada.
Status changed from Open to Closed
% Done changed from 0 to 100Applied in changeset r22652.¶
http://redmine.ruby-lang.org/issues/show/1219
--
There are some people who begin the Zoo at the beginning, called
WAYIN, and walk as quickly as they can past every cage until they get
to the one called WAYOUT, but the nicest people go straight to the
animal they love the most, and stay there. ~ A.A. Milne (from
Winnie-the-Pooh)
=end