Class: BabySqueel::JoinDependency
- Inherits:
-
Object
- Object
- BabySqueel::JoinDependency
- Defined in:
- lib/baby_squeel/join_dependency.rb
Instance Method Summary collapse
-
#constraints ⇒ Object
Converts an array of BabySqueel::Associations into an array of Arel join nodes.
-
#initialize(scope, associations = []) ⇒ JoinDependency
constructor
A new instance of JoinDependency.
Constructor Details
#initialize(scope, associations = []) ⇒ JoinDependency
Returns a new instance of JoinDependency.
3 4 5 6 |
# File 'lib/baby_squeel/join_dependency.rb', line 3 def initialize(scope, associations = []) @scope = scope @associations = associations end |
Instance Method Details
#constraints ⇒ Object
Converts an array of BabySqueel::Associations into an array of Arel join nodes.
Each association is built individually so that the correct Arel join node will be used for each individual association.
13 14 15 16 17 |
# File 'lib/baby_squeel/join_dependency.rb', line 13 def constraints @associations.each.with_index.inject([]) do |joins, (assoc, i)| inject @associations[0..i], joins, assoc._join end end |