In The ActiveSupport memory_store.rb @@@ def write(name, value, options = nil) super @data[name] = (value.duplicable? ? value.dup : value).freeze end @@@ This function freezes everything that gets written, according to the ruby doc once an object is frozen it cannot be unfrozen later: http://www.ruby-doc.org/core/classes/Object.html#M000356 so when I read an object from cache @@@ def read(name, options = nil) super @data[name] end @@@ how am I able to then write to it since its been frozen? Sorry I really don''t get this and been trying to understand it since the patch was posted. Thanks
anyone? On Oct 7, 2:07 pm, codex1 <jfagan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In The ActiveSupport memory_store.rb > > @@@ > def write(name, value, options = nil) > super > @data[name] = (value.duplicable? ? value.dup : value).freeze > end > @@@ > > This function freezes everything that gets written, according to the > ruby doc once an object is frozen it cannot be unfrozen later:http://www.ruby-doc.org/core/classes/Object.html#M000356 > > so when I read an object from cache > > @@@ > def read(name, options = nil) > super > @data[name] > end > @@@ > > how am I able to then write to it since its been frozen? Sorry I > really don''t get this and been trying to understand it since the patch > was posted. > > Thanks
Conrad Taylor
2009-Oct-21 10:31 UTC
Re: I thought frozen objects could not be unfrozen later
On Wed, Oct 21, 2009 at 2:43 AM, codex1 <jfagan365-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > anyone? > > On Oct 7, 2:07 pm, codex1 <jfagan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > In The ActiveSupport memory_store.rb > > > > @@@ > > def write(name, value, options = nil) > > super > > @data[name] = (value.duplicable? ? value.dup : value).freeze > > end > > @@@ > > > > This function freezes everything that gets written, according to the > > ruby doc once an object is frozen it cannot be unfrozen later: > http://www.ruby-doc.org/core/classes/Object.html#M000356 > > > > so when I read an object from cache > > > > @@@ > > def read(name, options = nil) > > super > > @data[name] > > end > > @@@ > > > > how am I able to then write to it since its been frozen? Sorry I > > really don''t get this and been trying to understand it since the patch > > was posted. > > > > Thanks >Where''s the actual test case that invalidates this code? -Conrad> > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2009-Oct-21 10:42 UTC
Re: I thought frozen objects could not be unfrozen later
On Wed, Oct 21, 2009 at 3:31 AM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Wed, Oct 21, 2009 at 2:43 AM, codex1 <jfagan365-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> anyone? >> >> On Oct 7, 2:07 pm, codex1 <jfagan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > In The ActiveSupport memory_store.rb >> > >> > @@@ >> > def write(name, value, options = nil) >> > super >> > @data[name] = (value.duplicable? ? value.dup : value).freeze >> > end >> > @@@ >> > >> >The above is freezing the value and not the container, @data, for the value. You can simply try this for yourself using irb. -Conrad> > This function freezes everything that gets written, according to the >> > ruby doc once an object is frozen it cannot be unfrozen later: >> http://www.ruby-doc.org/core/classes/Object.html#M000356 >> > >> > so when I read an object from cache >> > >> > @@@ >> > def read(name, options = nil) >> > super >> > @data[name] >> > end >> > @@@ >> > >> > how am I able to then write to it since its been frozen? Sorry I >> > really don''t get this and been trying to understand it since the patch >> > was posted. >> > >> > Thanks >> > > Where''s the actual test case that invalidates this code? > > -Conrad > > >> >> >> >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---