Module: Mixture::Extensions::Attributable::ClassMethods
- Defined in:
- lib/mixture/extensions/attributable.rb
Overview
The class methods for attribution.
Instance Method Summary collapse
-
#attribute(name, options = {}) ⇒ Attribute
Defines an attribute.
-
#attributes ⇒ AttributeList
The attribute list.
Instance Method Details
#attribute(name, options = {}) ⇒ Attribute
Defines an attribute. Defines the getter and the setter for for the attribute, the getter and setter alias to the #attribute.
16 17 18 19 20 21 22 |
# File 'lib/mixture/extensions/attributable.rb', line 16 def attribute(name, = {}) name = name.to_s.intern attr = attributes.create(name, ) define_method(attr.getter) { attribute(name) } define_method(attr.setter) { |v| attribute(name, v) } attr end |
#attributes ⇒ AttributeList
The attribute list. Acts as a hash for the attributes.
28 29 30 |
# File 'lib/mixture/extensions/attributable.rb', line 28 def attributes @_attributes ||= AttributeList.new end |