|
1 | 1 | require "polyamorous/version"
|
2 |
| -require 'active_record' |
3 | 2 |
|
4 |
| -module Polyamorous |
5 |
| - if defined?(::ActiveRecord::Associations::JoinDependency) |
6 |
| - JoinDependency = ::ActiveRecord::Associations::JoinDependency |
7 |
| - JoinAssociation = ::ActiveRecord::Associations::JoinDependency::JoinAssociation |
8 |
| - JoinBase = ::ActiveRecord::Associations::JoinDependency::JoinBase |
9 |
| - else |
10 |
| - JoinDependency = ::ActiveRecord::Associations::ClassMethods::JoinDependency |
11 |
| - JoinAssociation = ::ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation |
12 |
| - JoinBase = ::ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase |
| 3 | +if defined?(::ActiveRecord) |
| 4 | + module Polyamorous |
| 5 | + if defined?(::ActiveRecord::Associations::JoinDependency) |
| 6 | + JoinDependency = ::ActiveRecord::Associations::JoinDependency |
| 7 | + JoinAssociation = ::ActiveRecord::Associations::JoinDependency::JoinAssociation |
| 8 | + JoinBase = ::ActiveRecord::Associations::JoinDependency::JoinBase |
| 9 | + else |
| 10 | + JoinDependency = ::ActiveRecord::Associations::ClassMethods::JoinDependency |
| 11 | + JoinAssociation = ::ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation |
| 12 | + JoinBase = ::ActiveRecord::Associations::ClassMethods::JoinDependency::JoinBase |
| 13 | + end |
13 | 14 | end
|
14 |
| -end |
15 | 15 |
|
16 |
| -require 'polyamorous/join' |
17 |
| -require 'polyamorous/join_association' |
18 |
| -require 'polyamorous/join_dependency' |
| 16 | + require 'polyamorous/join' |
| 17 | + require 'polyamorous/join_association' |
| 18 | + require 'polyamorous/join_dependency' |
19 | 19 |
|
20 |
| -Polyamorous::JoinDependency.send(:include, Polyamorous::JoinDependencyExtensions) |
21 |
| -Polyamorous::JoinAssociation.send(:include, Polyamorous::JoinAssociationExtensions) |
22 |
| -Polyamorous::JoinBase.class_eval do |
23 |
| - if method_defined?(:active_record) |
24 |
| - alias_method :base_klass, :active_record |
| 20 | + Polyamorous::JoinDependency.send(:include, Polyamorous::JoinDependencyExtensions) |
| 21 | + Polyamorous::JoinAssociation.send(:include, Polyamorous::JoinAssociationExtensions) |
| 22 | + Polyamorous::JoinBase.class_eval do |
| 23 | + if method_defined?(:active_record) |
| 24 | + alias_method :base_klass, :active_record |
| 25 | + end |
25 | 26 | end
|
26 | 27 | end
|
0 commit comments