Class: BabySqueel::JoinDependency::Injector

Inherits:
Array
  • Object
show all
Defined in:
lib/baby_squeel/join_dependency/injector.rb

Overview

This class allows BabySqueel to slip custom joins_values into Active Record’s JoinDependency

Instance Method Summary collapse

Constructor Details

#initialize(joins) ⇒ Injector

:nodoc:



6
7
8
# File 'lib/baby_squeel/join_dependency/injector.rb', line 6

def initialize(joins)
  @joins = joins
end

Instance Method Details

#group_by(&block) ⇒ Object

Active Record will call group_by on this object in ActiveRecord::QueryMethods#build_joins. This allows BabySqueel::JoinExpressions to be treated like typical join hashes until Polyamorous can deal with them.



15
16
17
18
19
20
21
22
23
24
# File 'lib/baby_squeel/join_dependency/injector.rb', line 15

def group_by(&block)
  @joins.group_by do |join|
    case join
    when BabySqueel::JoinExpression
      :association_join
    else
      yield join
    end
  end
end