Class: ActiveRecord::ConnectionAdapters::CipherStashPG::OID::Interval
- Inherits:
-
Type::Value
- Object
- Type::Value
- ActiveRecord::ConnectionAdapters::CipherStashPG::OID::Interval
- Defined in:
- lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/interval.rb,
lib/active_record/connection_adapters/7.0/cipherstash_pg/oid/interval.rb,
lib/active_record/connection_adapters/7.1/cipherstash_pg/oid/interval.rb
Overview
:nodoc:
Instance Method Summary collapse
- #cast_value(value) ⇒ Object
- #serialize(value) ⇒ Object
- #type ⇒ Object
- #type_cast_for_schema(value) ⇒ Object
Instance Method Details
#cast_value(value) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/interval.rb', line 14 def cast_value(value) case value when ::ActiveSupport::Duration value when ::String begin ::ActiveSupport::Duration.parse(value) rescue ::ActiveSupport::Duration::ISO8601Parser::ParsingError nil end else super end end |
#serialize(value) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/interval.rb', line 29 def serialize(value) case value when ::ActiveSupport::Duration value.iso8601(precision: self.precision) when ::Numeric # Sometimes operations on Times returns just float number of seconds so we need to handle that. # Example: Time.current - (Time.current + 1.hour) # => -3600.000001776 (Float) value.seconds.iso8601(precision: self.precision) else super end end |
#type ⇒ Object
10 11 12 |
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/interval.rb', line 10 def type :interval end |
#type_cast_for_schema(value) ⇒ Object
42 43 44 |
# File 'lib/active_record/connection_adapters/6.1/cipherstash_pg/oid/interval.rb', line 42 def type_cast_for_schema(value) serialize(value).inspect end |