diff options
author | Jon Leighton <j@jonathanleighton.com> | 2010-10-21 17:35:07 +0100 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-10-30 06:30:00 -0700 |
commit | b82fab25f999dd6245c23a22f948048eef2d5d9a (patch) | |
tree | ea3a443035b94c0eda5ce051bd6a2f6aea7f96a7 /activerecord/lib/active_record/associations/through_association_scope.rb | |
parent | 2a47e7ef105559c4c931efff8fd14c454a21cf7a (diff) | |
download | rails-b82fab25f999dd6245c23a22f948048eef2d5d9a.tar.gz rails-b82fab25f999dd6245c23a22f948048eef2d5d9a.tar.bz2 rails-b82fab25f999dd6245c23a22f948048eef2d5d9a.zip |
Refactoring: replace the mix of variables like @finder_sql, @counter_sql, etc with just a single scope hash (created on initialization of the proxy). This is now used consistently across all associations. Therefore, all you have to do to ensure finding/counting etc is done correctly is implement the scope correctly.
Diffstat (limited to 'activerecord/lib/active_record/associations/through_association_scope.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/through_association_scope.rb | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/through_association_scope.rb b/activerecord/lib/active_record/associations/through_association_scope.rb index cabb33c4a8..bd8e304e99 100644 --- a/activerecord/lib/active_record/associations/through_association_scope.rb +++ b/activerecord/lib/active_record/associations/through_association_scope.rb @@ -5,16 +5,20 @@ module ActiveRecord protected - def construct_scope - { :create => construct_owner_attributes(@reflection), - :find => { :conditions => construct_conditions, - :joins => construct_joins, - :include => @reflection.options[:include] || @reflection.source_reflection.options[:include], - :select => construct_select, - :order => @reflection.options[:order], - :limit => @reflection.options[:limit], - :readonly => @reflection.options[:readonly], - } } + def construct_find_scope + { + :conditions => construct_conditions, + :joins => construct_joins, + :include => @reflection.options[:include] || @reflection.source_reflection.options[:include], + :select => construct_select, + :order => @reflection.options[:order], + :limit => @reflection.options[:limit], + :readonly => @reflection.options[:readonly] + } + end + + def construct_create_scope + construct_owner_attributes(@reflection) end # Build SQL conditions from attributes, qualified by table name. |