Sha256: 01384b948dbf3cf239ef42a4db3660b179c46ebf5731641166a3d5f49fd1c572

Contents?: true

Size: 1.58 KB

Versions: 7

Compression:

Stored size: 1.58 KB

Contents

# frozen_string_literal: true

require 'rails_compatibility'
require 'rails_compatibility/construct_join_dependency'
require 'rails_compatibility/active_record'

class << RailsCompatibility
  if GTE_RAILS_6_1
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      joins = join_dependency.join_constraints([], relation.alias_tracker, relation.references_values)
      return joins
    end
  elsif GTE_RAILS_6_0
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      joins = join_dependency.join_constraints([], relation.alias_tracker)
      return joins
    end
  elsif GTE_RAILS_5_2
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      joins = join_dependency.join_constraints([], Arel::Nodes::InnerJoin, relation.alias_tracker)
      return joins
    end
  elsif GTE_RAILS_5_0
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      info = join_dependency.join_constraints([], Arel::Nodes::InnerJoin)[0]
      return info.joins
    end
  elsif GTE_RAILS_4_0
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      info = join_dependency.join_constraints([])[0]
      return info.joins
    end
  else
    def build_joins(reflect, relation)
      join_dependency = construct_join_dependency(reflect, relation)
      return join_dependency.join_associations
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_compatibility-0.0.10 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.9 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.8 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.7 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.6 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.4 lib/rails_compatibility/build_joins.rb
rails_compatibility-0.0.3 lib/rails_compatibility/build_joins.rb