Class: BabySqueel::JoinExpression
- Inherits:
-
Object
- Object
- BabySqueel::JoinExpression
- Includes:
- Polyamorous::TreeNode
- Defined in:
- lib/baby_squeel/join_expression.rb
Overview
This is the thing that gets added to Active Record’s joins_values. By including Polyamorous::TreeNode, when this instance is found when traversing joins in ActiveRecord::Associations::JoinDependency::walk_tree, JoinExpression#add_to_tree will be called.
Instance Method Summary collapse
-
#add_to_tree(hash) ⇒ Object
Each individual association object knows how to build a Polyamorous::Join.
-
#initialize(associations) ⇒ JoinExpression
constructor
A new instance of JoinExpression.
Constructor Details
#initialize(associations) ⇒ JoinExpression
Returns a new instance of JoinExpression.
9 10 11 |
# File 'lib/baby_squeel/join_expression.rb', line 9 def initialize(associations) @associations = associations end |
Instance Method Details
#add_to_tree(hash) ⇒ Object
Each individual association object knows how to build a Polyamorous::Join. Those joins will be added to the hash incrementally.
16 17 18 19 20 |
# File 'lib/baby_squeel/join_expression.rb', line 16 def add_to_tree(hash) @associations.inject(hash) do |acc, assoc| assoc.add_to_tree(acc) end end |