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
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/chrono_model/time_machine.rb', line 374 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 |