Class: ActiveFields::Casters::DateCaster

Inherits:
BaseCaster
  • Object
show all
Defined in:
lib/active_fields/casters/date_caster.rb

Direct Known Subclasses

DateArrayCaster

Instance Attribute Summary

Attributes inherited from BaseCaster

#options

Instance Method Summary collapse

Methods inherited from BaseCaster

#initialize

Constructor Details

This class inherits a constructor from ActiveFields::Casters::BaseCaster

Instance Method Details

#deserialize(value) ⇒ Object



12
13
14
15
16
# File 'lib/active_fields/casters/date_caster.rb', line 12

def deserialize(value)
  casted_value = caster.deserialize(value)

  casted_value if casted_value.is_a?(Date)
end

#serialize(value) ⇒ Object



6
7
8
9
10
# File 'lib/active_fields/casters/date_caster.rb', line 6

def serialize(value)
  casted_value = caster.serialize(value)

  casted_value.iso8601 if casted_value.is_a?(Date)
end