Module: ClassLevelInheritableAttributes::ClassMethods

Defined in:
lib/six-updater-web/vendor/plugins/rave_embed/lib/rave_embed/cattr_inheritable.rb

Instance Method Summary collapse

Instance Method Details

#cattr_inheritable(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/six-updater-web/vendor/plugins/rave_embed/lib/rave_embed/cattr_inheritable.rb', line 7

def cattr_inheritable(*args)
  @cattr_inheritable_attrs ||= [:cattr_inheritable_attrs]
  @cattr_inheritable_attrs += args
  args.each do |arg|
    class_eval %(
      class << self; attr_accessor :#{arg} end
    )
  end
  @cattr_inheritable_attrs
end

#inherited(subclass) ⇒ Object



18
19
20
21
22
23
# File 'lib/six-updater-web/vendor/plugins/rave_embed/lib/rave_embed/cattr_inheritable.rb', line 18

def inherited(subclass)
  @cattr_inheritable_attrs.each do |inheritable_attribute|
    instance_var = "@#{inheritable_attribute}" 
    subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
  end
end