Class: ChronoModel::Adapter::TSRange
- Inherits:
-
ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Range
- Object
- ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Range
- ChronoModel::Adapter::TSRange
- Defined in:
- lib/chrono_model/adapter.rb
Overview
HACK: Redefine tsrange parsing support, as it is broken currently.
This self-made API is here because currently AR4 does not support open-ended ranges. The reasons are poor support in Ruby:
https://bugs.ruby-lang.org/issues/6864
and an instable interface in Active Record:
https://github.com/rails/rails/issues/13793
https://github.com/rails/rails/issues/14010
so, for now, we are implementing our own.
Constant Summary collapse
- OID =
3908
Instance Method Summary collapse
Instance Method Details
#cast_value(value) ⇒ Object
491 492 493 494 495 496 497 498 499 500 501 |
# File 'lib/chrono_model/adapter.rb', line 491 def cast_value(value) return if value == 'empty' return value if value.is_a?(::Array) extracted = extract_bounds(value) from = Conversions.string_to_utc_time extracted[:from] to = Conversions.string_to_utc_time extracted[:to ] [from, to] end |
#extract_bounds(value) ⇒ Object
503 504 505 506 507 508 509 |
# File 'lib/chrono_model/adapter.rb', line 503 def extract_bounds(value) from, to = value[1..-2].split(',') { from: (value[1] == ',' || from == '-infinity') ? nil : from[1..-2], to: (value[-2] == ',' || to == 'infinity') ? nil : to[1..-2], } end |