Class: ChronoModel::Patches::JoinNode

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

Overview

This class supports the AR 4.2 code that expects to receive an Arel::Table as the left join node. We need to replace the node with a virtual table that fetches from the history at a given point in time, we replace the join node with a SqlLiteral node that does not respond to the methods that AR expects.

This class provides AR with an object implementing the methods it expects, yet producing SQL that fetches from history tables as-of-time.

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.


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/chrono_model/patches.rb', line 39

def initialize(join_node, history_model, as_of_time)
  @name        = join_node.table_name
  @table_name  = join_node.table_name
  @table_alias = join_node.table_alias

  @as_of_time  = as_of_time

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

  super(virtual_table)
end

Instance Attribute Details

#as_of_timeObject (readonly)

Returns the value of attribute as_of_time


37
38
39
# File 'lib/chrono_model/patches.rb', line 37

def as_of_time
  @as_of_time
end

#nameObject (readonly)

Returns the value of attribute name


37
38
39
# File 'lib/chrono_model/patches.rb', line 37

def name
  @name
end

#table_aliasObject (readonly)

Returns the value of attribute table_alias


37
38
39
# File 'lib/chrono_model/patches.rb', line 37

def table_alias
  @table_alias
end

#table_nameObject (readonly)

Returns the value of attribute table_name


37
38
39
# File 'lib/chrono_model/patches.rb', line 37

def table_name
  @table_name
end