Class: CouchbaseOrm::Types::Timestamp
- Inherits:
-
ActiveModel::Type::DateTime
- Object
- ActiveModel::Type::DateTime
- CouchbaseOrm::Types::Timestamp
- Defined in:
- lib/couchbase-orm/types/timestamp.rb
Instance Method Summary collapse
Instance Method Details
#cast(value) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/couchbase-orm/types/timestamp.rb', line 4 def cast(value) return nil if value.nil? return Time.at(value) if value.is_a?(Integer) || value.is_a?(Float) return Time.at(value.to_i) if value.is_a?(String) && value =~ /^[0-9]+$/ return value.utc if value.is_a?(Time) super(value).utc end |
#serialize(value) ⇒ Object
12 13 14 |
# File 'lib/couchbase-orm/types/timestamp.rb', line 12 def serialize(value) value&.to_i end |