Class: CouchbaseOrm::Types::DateTime

Inherits:
ActiveModel::Type::DateTime
  • Object
show all
Defined in:
lib/couchbase-orm/types/date_time.rb

Instance Method Summary collapse

Instance Method Details

#cast(value) ⇒ Object



6
7
8
9
# File 'lib/couchbase-orm/types/date_time.rb', line 6

def cast(value)
  value = Time.at(value) if value.is_a?(Float) || value.is_a?(Integer)
  super(value)&.utc
end

#serialize(value) ⇒ Object



11
12
13
# File 'lib/couchbase-orm/types/date_time.rb', line 11

def serialize(value)
  value&.iso8601(@precision)
end