Flowdock

Notes posted by awendt

RSS feed
April 21, 2009
1 thank

Merges with inherited values from super class

http://www.spacevatican.org/2008/8/19/fun-with-class-variables

When you set a class_inheritable_array or a class_inheritable_hash you are actually concatenating (or merging) with the value inherited from the super class.”

Code example

class Base
  class_inheritable_hash :attrs
  self.attrs = {:name => 'Fred'}
end

class Derived < Base
  self.attrs = {:export => 'Pain'}
end

Derived.attrs #=> {:name => 'Fred', :export => 'Pain'}