Module: Morpheus::TypeCaster
Instance Method Summary collapse
Instance Method Details
#cast(value, typecast_class) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/morpheus/type_caster.rb', line 5 def cast(value, typecast_class) case typecast_class when NilClass value when :string parse_string(value) when :integer parse_integer(value) when :datetime parse_datetime(value) when :date parse_date(value) when :time parse_time(value) when :boolean parse_boolean(value) else raise UnrecognizedTypeCastClass, "Can't typecast to #{typecast_class}!" end end |