module ClassLevelInheritableAttributes::ClassMethods

Public Instance Methods

class_inheritable_attributes(*args) click to toggle source
# File lib/class_level_inheritable_attributes.rb, line 7
def class_inheritable_attributes(*args)
  @xeroizer_inheritable_attributes ||= [:inheritable_attributes]
  @xeroizer_inheritable_attributes += args
  args.each do |arg|
    class_eval %(
      class << self; attr_accessor :#{arg} end
    )
  end
  @xeroizer_inheritable_attributes
end
inherited(subclass) click to toggle source
# File lib/class_level_inheritable_attributes.rb, line 18
def inherited(subclass)
  original_verbose, $VERBOSE = $VERBOSE, nil
  @xeroizer_inheritable_attributes.each do |inheritable_attribute|
    instance_var = "@#{inheritable_attribute}"
    subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))
  end
  $VERBOSE = original_verbose

end