Class: Mixture::Attribute
- Inherits:
-
Object
- Object
- Mixture::Attribute
- Defined in:
- lib/mixture/attribute.rb
Overview
An attribute for a mixture object.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #getter ⇒ Object
-
#initialize(name, list, options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
- #ivar ⇒ Object
- #setter ⇒ Object
- #update(value) ⇒ Object
Constructor Details
#initialize(name, list, options = {}) ⇒ Attribute
Returns a new instance of Attribute.
9 10 11 12 13 |
# File 'lib/mixture/attribute.rb', line 9 def initialize(name, list, = {}) @name = name @list = list @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/mixture/attribute.rb', line 6 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/mixture/attribute.rb', line 7 def @options end |
Instance Method Details
#getter ⇒ Object
23 24 25 |
# File 'lib/mixture/attribute.rb', line 23 def getter @name end |
#ivar ⇒ Object
19 20 21 |
# File 'lib/mixture/attribute.rb', line 19 def ivar @_ivar ||= :"@#{@name}" end |
#setter ⇒ Object
27 28 29 |
# File 'lib/mixture/attribute.rb', line 27 def setter @_setter ||= :"#{@name}=" end |
#update(value) ⇒ Object
15 16 17 |
# File 'lib/mixture/attribute.rb', line 15 def update(value) @list.callbacks[:update].inject(value) { |a, e| e.call(self, a) } end |