Sha256: c9eb8ea9bcb0bd715cab3a1384968120d552bf624030e907622a54ab069fb1cd

Contents?: true

Size: 704 Bytes

Versions: 6

Compression:

Stored size: 704 Bytes

Contents

module Polyamorous
  module JoinAssociationExtensions
    include SwappingReflectionClass
    def self.prepended(base)
      base.class_eval { attr_reader :join_type }
    end

    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

    def ==(other)
      base_klass == other.base_klass
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
ransack-2.5.0 lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/ransack-2.4.2/lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
ransack-2.4.2 lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
ransack-2.4.1 lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb
ransack-2.4.0 lib/polyamorous/activerecord_5.2_ruby_2/join_association.rb