Module: Polyamorous::JoinAssociationExtensions

Includes:
SwappingReflectionClass
Defined in:
lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SwappingReflectionClass

#swapping_reflection_klass

Class Method Details

.prepended(base) ⇒ Object



4
5
6
# File 'lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb', line 4

def self.prepended(base)
  base.class_eval { attr_reader :join_type }
end

Instance Method Details

#initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb', line 8

def initialize(reflection, children, polymorphic_class = nil, join_type = Arel::Nodes::InnerJoin)
  @join_type = join_type
  if polymorphic_class && ::ActiveRecord::Base > polymorphic_class
    swapping_reflection_klass(reflection, polymorphic_class) do |reflection|
      super(reflection, children)
      self.reflection.options[:polymorphic] = true
    end
  else
    super(reflection, children)
  end
end