Module: Ohm::DataTypes::Type

Defined in:
lib/ohm/datatypes.rb

Constant Summary collapse

Integer =
->(x) { x.to_i }
Decimal =
->(x) { BigDecimal(x.to_s) }
Float =
->(x) { x.to_f }
Symbol =
->(x) { x && x.to_sym }
Boolean =
->(x) { !!x }
Time =
->(t) { t && (t.kind_of?(::Time) ? t : ::Time.parse(t)) }
Date =
->(d) { d && (d.kind_of?(::Date) ? d : ::Date.parse(d)) }
Timestamp =
->(t) { t && UnixTime.at(t.to_i) }
Hash =
->(h) { h && SerializedHash[h.kind_of?(::Hash) ? h : JSON(h)] }
Array =
->(a) { a && SerializedArray.new(a.kind_of?(::Array) ? a : JSON(a)) }
Set =
->(s) { s && SerializedSet.new(s.kind_of?(::Set) ? s : JSON(s)) }