Module: ActiveAttr::Typecasting

Defined in:
lib/active_attr_extended.rb

Constant Summary collapse

TYPECASTER_MAP =
{
    Array      => ::ActiveAttrExtended::Typecasting::ArrayTypecaster,
    BigDecimal => BigDecimalTypecaster,
    Boolean    => BooleanTypecaster,
    Date       => DateTypecaster,
    DateTime   => DateTimeTypecaster,
    Float      => FloatTypecaster,
    Hash       => ::ActiveAttrExtended::Typecasting::HashTypecaster,
    Integer    => IntegerTypecaster,
    Object     => ObjectTypecaster,
    String     => StringTypecaster
}.freeze

Instance Method Summary collapse

Instance Method Details

#typecaster_for(type) ⇒ Object

redefine for active_attr <= 0.7.0



29
30
31
32
# File 'lib/active_attr_extended.rb', line 29

def typecaster_for(type)
  typecaster = TYPECASTER_MAP[type]
  typecaster.new if typecaster
end