Module: Things::Reference::Inheritance
- Included in:
- Record
- Defined in:
- lib/things/reference/inheritance.rb
Instance Method Summary collapse
Instance Method Details
#inheritable_attributes(*args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/things/reference/inheritance.rb', line 7 def inheritable_attributes(*args) @inheritable_attributes ||= [:inheritable_attributes] @inheritable_attributes += args args.each do |arg| class_eval %( class << self; attr_accessor :#{arg} end ) end @inheritable_attributes end |
#inherited(subclass) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/things/reference/inheritance.rb', line 18 def inherited(subclass) @inheritable_attributes.each do |inheritable_attribute| instance_var = "@#{inheritable_attribute}" subclass.instance_variable_set(instance_var, instance_variable_get(instance_var)) end end |