Class: Attrio::DefaultValue::Base
- Defined in:
- lib/attrio/default_value/base.rb
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#call(instance) ⇒ Object
Evaluates the value.
-
#initialize(attribute, value) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(attribute, value) ⇒ Base
Returns a new instance of Base.
18 19 20 |
# File 'lib/attrio/default_value/base.rb', line 18 def initialize(attribute, value) @attribute = attribute; @value = value; end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
6 7 8 |
# File 'lib/attrio/default_value/base.rb', line 6 def attribute @attribute end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/attrio/default_value/base.rb', line 6 def value @value end |
Class Method Details
.handle(attribute, value) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/attrio/default_value/base.rb', line 8 def self.handle(attribute, value) handler = [ Attrio::DefaultValue::Callable, Attrio::DefaultValue::Clonable, Attrio::DefaultValue::Symbol ].detect{ |handler| handler.handle?(value) } handler.new(attribute, value) if handler.present? end |
Instance Method Details
#call(instance) ⇒ Object
Evaluates the value
25 26 27 |
# File 'lib/attrio/default_value/base.rb', line 25 def call(instance) raise NotImplementedError end |