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
6 7 8 9 10 11 12 13 |
# File 'lib/couchbase-orm/types/timestamp.rb', line 6 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
15 16 17 |
# File 'lib/couchbase-orm/types/timestamp.rb', line 15 def serialize(value) value&.to_i end |