Module: TemporalTables::ArelTable

Defined in:
lib/temporal_tables/arel_table.rb

Overview

This is required for eager_load to work

Instance Method Summary collapse

Instance Method Details

#create_join(to, constraint = nil, klass = Arel::Nodes::InnerJoin) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/temporal_tables/arel_table.rb', line 6

def create_join(to, constraint = nil, klass = Arel::Nodes::InnerJoin)
  join = super
  at_value = Thread.current[:at_time]
  if at_value
    join =
      join
      .and(to[:eff_to].gt(at_value).or(to[:eff_to].eq(TemporalTables::END_OF_TIME)))
      .and(to[:eff_from].lteq(at_value))
  end
  join
end