Class: Virtus::Attribute::DefaultValue::FromSymbol Private
- Inherits:
-
Virtus::Attribute::DefaultValue
- Object
- Virtus::Attribute::DefaultValue
- Virtus::Attribute::DefaultValue::FromSymbol
- Defined in:
- lib/virtus/attribute/default_value/from_symbol.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 symbol
Instance Attribute Summary
Attributes inherited from Virtus::Attribute::DefaultValue
Class Method Summary collapse
-
.handle?(value) ⇒ Boolean
private
Return if the class can handle the value.
Instance Method Summary collapse
-
#call(instance, _) ⇒ Object
private
Evaluates the value via instance#public_send(value).
Methods inherited from Virtus::Attribute::DefaultValue
Constructor Details
This class inherits a constructor from Virtus::Attribute::DefaultValue
Class Method Details
.handle?(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
17 18 19 |
# File 'lib/virtus/attribute/default_value/from_symbol.rb', line 17 def self.handle?(value) value.is_a?(Symbol) end |
Instance Method Details
#call(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 instance#public_send(value)
Symbol value is returned if the instance doesn’t respond to value
28 29 30 |
# File 'lib/virtus/attribute/default_value/from_symbol.rb', line 28 def call(instance, _) instance.respond_to?(@value, true) ? instance.send(@value) : @value end |