diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-13 15:40:18 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-13 15:40:18 -0800 |
commit | 7d897abeccb8533d770ac1d0768eca20ec2f3971 (patch) | |
tree | d654e0a689866b509f237908081ac71d55815000 /activerecord/lib | |
parent | e804d07a92498b3c3565c4178d0ac591c5934cd2 (diff) | |
download | rails-7d897abeccb8533d770ac1d0768eca20ec2f3971.tar.gz rails-7d897abeccb8533d770ac1d0768eca20ec2f3971.tar.bz2 rails-7d897abeccb8533d770ac1d0768eca20ec2f3971.zip |
remove more delegate methods
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/association_scope.rb | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index dcd2cbcbd5..15691e26df 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -3,8 +3,8 @@ module ActiveRecord class AssociationScope #:nodoc: attr_reader :association, :alias_tracker - delegate :klass, :owner, :reflection, :to => :association - delegate :chain, :scope_chain, :options, :to => :reflection + delegate :klass, :reflection, :to => :association + delegate :chain, :scope_chain, :to => :reflection def initialize(association) @association = association @@ -13,8 +13,10 @@ module ActiveRecord def scope scope = klass.unscoped - scope.extending! Array(options[:extend]) - add_constraints(scope) + scope.extending! Array(reflection.options[:extend]) + + owner = association.owner + add_constraints(scope, owner) end def join_type @@ -59,7 +61,7 @@ module ActiveRecord bind_value scope, column, value end - def add_constraints(scope) + def add_constraints(scope, owner) tables = construct_tables chain.each_with_index do |reflection, i| @@ -105,7 +107,7 @@ module ActiveRecord # Exclude the scope of the association itself, because that # was already merged in the #scope method. scope_chain[i].each do |scope_chain_item| - item = eval_scope(klass, scope_chain_item) + item = eval_scope(klass, scope_chain_item, owner) if scope_chain_item == self.reflection.scope scope.merge! item.except(:where, :includes, :bind) @@ -138,7 +140,7 @@ module ActiveRecord end end - def eval_scope(klass, scope) + def eval_scope(klass, scope, owner) if scope.is_a?(Relation) scope else |