Class: ActiveType::VirtualAttributes::VirtualColumn
- Inherits:
-
Object
- Object
- ActiveType::VirtualAttributes::VirtualColumn
- Defined in:
- lib/active_type/virtual_attributes.rb
Instance Method Summary collapse
- #default_value(object) ⇒ Object
-
#initialize(name, type_caster, options) ⇒ VirtualColumn
constructor
A new instance of VirtualColumn.
- #type_cast(value) ⇒ Object
Constructor Details
#initialize(name, type_caster, options) ⇒ VirtualColumn
Returns a new instance of VirtualColumn.
30 31 32 33 34 |
# File 'lib/active_type/virtual_attributes.rb', line 30 def initialize(name, type_caster, ) @name = name @type_caster = type_caster @options = end |
Instance Method Details
#default_value(object) ⇒ Object
40 41 42 43 |
# File 'lib/active_type/virtual_attributes.rb', line 40 def default_value(object) default = @options[:default] default.respond_to?(:call) ? object.instance_eval(&default) : default end |
#type_cast(value) ⇒ Object
36 37 38 |
# File 'lib/active_type/virtual_attributes.rb', line 36 def type_cast(value) @type_caster.type_cast_from_user(value) end |