Hi Nick,
On Fri, Jan 21, 2011 at 12:41 PM, Nick Sutterer wrote:
> According to the docs, class_attribute does implement inheritance for
> class instance variables. However, it doesn't work as it is intended
> to, at least if you use "mutual structures", like Hash.
>
> Base.foo = {}
> Subclass.foo
> Ouch - that's absolutely right. So worst case is
> that in my solution you might still operate on a superclass object.
> Let me think about that!
We have several different options for this depending on the semantics
you're after for your 'class variable things'.
https://gith
On 21 Jan., 22:27, Matt Jones wrote:
> On Jan 21, 2011, at 3:41 PM, Nick Sutterer wrote:
>
> > By accident I solved this with a 10-liner months ago, why not use
> > something like
> > that?https://github.com/apotonick/hooks/blob/master/lib/hooks/inheritable_...
>
> > It's simple, clean and does
On Jan 21, 2011, at 3:41 PM, Nick Sutterer wrote:
> By accident I solved this with a 10-liner months ago, why not use
> something like that?
> https://github.com/apotonick/hooks/blob/master/lib/hooks/inheritable_attribute.rb
>
> It's simple, clean and does exactly what you expect.
>
Well, as
> Please have a look also to the section about class inheritable attributes.
>
Do you basically say what I want is class_inheritable_hash ?
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to rubyonrails-
On Fri, Jan 21, 2011 at 9:41 PM, Nick Sutterer wrote:
> According to the docs, class_attribute does implement inheritance for
> class instance variables. However, it doesn't work as it is intended
> to, at least if you use "mutual structures", like Hash.
>
> Base.foo = {}
> Subclass.foo[:bar] = "
> I'm sorry, but this is WRONG and dangerous. The docs tell me to "use
> setters" here - not sure how this is supposed to work.
>
No offense meant - just like "somewhat less than perfect" ;-)
> Another "solution" is to initialize the ivar in the subclass, again,
> as done here:https://github.com/
I like Nick's implementation, not everyone know or remembers that
modyfing object like Hash or Array will also change the superclass
(which is clearly visible in the commit that Nick's linked - that was
exactly the reason of the bug that I was fixing).
I think that it would be nice to have inherit
According to the docs, class_attribute does implement inheritance for
class instance variables. However, it doesn't work as it is intended
to, at least if you use "mutual structures", like Hash.
Base.foo = {}
Subclass.foo[:bar] = "bar"
Base.foo # => {:bar => "bar"}
I'm sorry, but this is WRONG a