Module: NYNY::Inheritable

Included in:
Base
Defined in:
lib/nyny/primitives.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/nyny/primitives.rb', line 7

def self.included base
  base.class_eval do
    def self.inheritable name, value
      @_inheritables ||= []
      @_inheritables << name
      self.class.send :attr_accessor, name
      self.send "#{name}=", value
    end

    def self.inherited subclass
      @_inheritables.each do |attr|
        subclass.inheritable attr, self.send(attr).deep_dup
      end
    end
  end
end