We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ecdc128 commit 5c56c77Copy full SHA for 5c56c77
1 file changed
lib/couchbase-orm/types/timestamp.rb
@@ -2,20 +2,13 @@ module CouchbaseOrm
2
module Types
3
class Timestamp < ActiveModel::Type::DateTime
4
def cast(value)
5
- return nil if value.nil?
6
-
7
- value = if value.is_a?(Integer) || value.is_a?(Float)
8
- Time.at(value)
9
- elsif value.is_a?(String) && value =~ /^[0-9]+$/
10
- Time.at(value.to_i)
11
- elsif value.is_a?(Time)
12
- value.utc
13
- else
14
- value
15
- end
16
- super(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
17
end
18
+
19
def serialize(value)
20
value&.to_i
21
0 commit comments