Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions lib/ohm/datatypes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,12 @@ module Type
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) }
Timestamp = ->(t) { t && Time.at(t.to_f) }
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)) }
end

class UnixTime < Time
def to_s
to_i.to_s
end
end

class SerializedHash < Hash
def to_s
JSON.dump(self)
Expand Down