Class: Virtus::Attribute::DefaultValue::FromCallable Private
- Inherits:
-
Virtus::Attribute::DefaultValue
- Object
- Virtus::Attribute::DefaultValue
- Virtus::Attribute::DefaultValue::FromCallable
- Defined in:
- lib/virtus/attribute/default_value/from_callable.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Represents default value evaluated via a callable object
Instance Attribute Summary
Attributes inherited from Virtus::Attribute::DefaultValue
Class Method Summary collapse
-
.handle?(attribute, value) ⇒ Boolean
private
Return if the class can handle the value.
Instance Method Summary collapse
-
#evaluate(instance) ⇒ Object
private
Evaluates the value via value#call.
Methods inherited from Virtus::Attribute::DefaultValue
Methods included from DescendantsTracker
Constructor Details
This class inherits a constructor from Virtus::Attribute::DefaultValue
Class Method Details
.handle?(attribute, value) ⇒ Boolean
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.
Return if the class can handle the value
15 16 17 |
# File 'lib/virtus/attribute/default_value/from_callable.rb', line 15 def self.handle?(attribute, value) value.respond_to?(:call) end |
Instance Method Details
#evaluate(instance) ⇒ 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.
Evaluates the value via value#call
26 27 28 |
# File 'lib/virtus/attribute/default_value/from_callable.rb', line 26 def evaluate(instance) @value.call(instance, @attribute) end |