Module: ChronoModel::TimeMachine::TimeQuery
- Included in:
- HistoryMethods
- Defined in:
- lib/chrono_model/time_machine.rb
Instance Method Summary collapse
-
#time_query(match, time, options) ⇒ Object
TODO Documentation.
Instance Method Details
#time_query(match, time, options) ⇒ Object
TODO Documentation
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
# File 'lib/chrono_model/time_machine.rb', line 347 def time_query(match, time, ) range = columns_hash.fetch([:on].to_s) query = case match when :at build_time_query_at(time, range) when :not "NOT (#{build_time_query_at(time, range)})" when :before op = .fetch(:inclusive, true) ? '&&' : '@>' build_time_query(['NULL', time_for_time_query(time, range)], range, op) when :after op = .fetch(:inclusive, true) ? '&&' : '@>' build_time_query([time_for_time_query(time, range), 'NULL'], range, op) else raise ArgumentError, "Invalid time_query: #{match}" end where(query) end |