Class: ChronoModel::Patches::JoinNode

Inherits:
Arel::Nodes::SqlLiteral
  • Object
show all
Defined in:
lib/chrono_model/patches/join_node.rb

Overview

Replaces the left side of an Arel join (table or table alias) with a SQL literal pointing to the history virtual table at the given as_of_time, preserving any existing table alias.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(join_node, history_model, as_of_time) ⇒ JoinNode

Returns a new instance of JoinNode.



11
12
13
14
15
16
17
18
# File 'lib/chrono_model/patches/join_node.rb', line 11

def initialize(join_node, history_model, as_of_time)
  @as_of_time  = as_of_time

  table_name = join_node.table_alias || join_node.name
  virtual_table = history_model.virtual_table_at(@as_of_time, table_name: table_name)

  super(virtual_table)
end

Instance Attribute Details

#as_of_timeObject (readonly)

Returns the value of attribute as_of_time.



9
10
11
# File 'lib/chrono_model/patches/join_node.rb', line 9

def as_of_time
  @as_of_time
end