Module: Hanami::Utils::ClassAttribute::ClassMethods Private
- Defined in:
- lib/hanami/utils/class_attribute.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .extended(base) ⇒ Object private
Instance Method Summary collapse
-
#class_attribute(*attributes) ⇒ void
private
Defines a class level accessor for the given attribute(s).
Class Method Details
.extended(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 |
# File 'lib/hanami/utils/class_attribute.rb', line 20 def self.extended(base) base.class_eval do @__class_attributes = Attributes.new unless defined?(@__class_attributes) end end |
Instance Method Details
#class_attribute(*attributes) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Defines a class level accessor for the given attribute(s).
A value set for a superclass is automatically available by their subclasses, unless a different value is explicitely set within the inheritance chain.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/hanami/utils/class_attribute.rb', line 75 def class_attribute(*attributes) attributes.each do |attr| singleton_class.class_eval %( def #{attr} # def foo class_attributes[:#{attr}] # class_attributes[:foo] end # end # def #{attr}=(value) # def foo=(value) class_attributes[:#{attr}] = value # class_attributes[:foo] = value end # end ), __FILE__, __LINE__ - 8 end end |