2018-06-23 13:00:21 -04:00
|
|
|
if defined?(::ActiveRecord)
|
|
|
|
module Polyamorous
|
2018-08-18 04:20:54 -04:00
|
|
|
InnerJoin = Arel::Nodes::InnerJoin
|
|
|
|
OuterJoin = Arel::Nodes::OuterJoin
|
2018-06-23 13:00:21 -04:00
|
|
|
|
2018-08-18 04:05:21 -04:00
|
|
|
JoinDependency = ::ActiveRecord::Associations::JoinDependency
|
|
|
|
JoinAssociation = ::ActiveRecord::Associations::JoinDependency::JoinAssociation
|
2018-06-23 13:00:21 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
require 'polyamorous/tree_node'
|
|
|
|
require 'polyamorous/join'
|
|
|
|
require 'polyamorous/swapping_reflection_class'
|
|
|
|
|
|
|
|
ar_version = ::ActiveRecord::VERSION::STRING[0,3]
|
2018-07-31 04:41:25 -04:00
|
|
|
ar_version = ::ActiveRecord::VERSION::STRING[0,5] if ar_version >= '5.2'
|
2018-06-23 13:00:21 -04:00
|
|
|
|
|
|
|
%w(join_association join_dependency).each do |file|
|
2018-07-02 11:00:34 -04:00
|
|
|
require "polyamorous/activerecord_#{ar_version}_ruby_2/#{file}"
|
2018-06-23 13:00:21 -04:00
|
|
|
end
|
|
|
|
|
2018-07-02 11:00:34 -04:00
|
|
|
Polyamorous::JoinDependency.send(:prepend, Polyamorous::JoinDependencyExtensions)
|
|
|
|
Polyamorous::JoinDependency.singleton_class.send(:prepend, Polyamorous::JoinDependencyExtensions::ClassMethods)
|
|
|
|
Polyamorous::JoinAssociation.send(:prepend, Polyamorous::JoinAssociationExtensions)
|
2018-06-23 13:00:21 -04:00
|
|
|
end
|