diff options
author | Xavier Noria <fxn@hashref.com> | 2010-06-30 20:47:26 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-06-30 20:47:26 +0200 |
commit | c63cf7bf0db708fe46a929cf57649ab5a92034af (patch) | |
tree | 8f0974852b51597652e6ae73da26f3eb80fe878b /activerecord/lib/active_record/relation/query_methods.rb | |
parent | 52c56f9f7ec46ee39f1a6319ff4017e2492683ed (diff) | |
parent | b07e6fdaa0aa07016d1425ada5b7f966142d0212 (diff) | |
download | rails-c63cf7bf0db708fe46a929cf57649ab5a92034af.tar.gz rails-c63cf7bf0db708fe46a929cf57649ab5a92034af.tar.bz2 rails-c63cf7bf0db708fe46a929cf57649ab5a92034af.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'activerecord/lib/active_record/relation/query_methods.rb')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 015ca8c24c..4692271266 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -15,12 +15,10 @@ module ActiveRecord end def eager_load(*args) - args.reject! { |a| a.blank? } clone.tap { |r| r.eager_load_values += args if args.present? } end def preload(*args) - args.reject! { |a| a.blank? } clone.tap { |r| r.preload_values += args if args.present? } end @@ -28,29 +26,24 @@ module ActiveRecord if block_given? to_a.select { |*block_args| yield(*block_args) } else - args.reject! { |a| a.blank? } clone.tap { |r| r.select_values += args if args.present? } end end def group(*args) - args.reject! { |a| a.blank? } clone.tap { |r| r.group_values += args if args.present? } end def order(*args) - args.reject! { |a| a.blank? } clone.tap { |r| r.order_values += args if args.present? } end def reorder(*args) - args.reject! { |a| a.blank? } clone.tap { |r| r.order_values = args if args.present? } end def joins(*args) args.flatten! - args.reject! { |a| a.blank? } clone.tap { |r| r.joins_values += args if args.present? } end @@ -93,8 +86,9 @@ module ActiveRecord clone.tap { |r| r.from_value = value } end - def extending(*modules) - clone.tap { |r| r.send :apply_modules, *modules } + def extending(*modules, &block) + modules << Module.new(&block) if block_given? + clone.tap { |r| r.send(:apply_modules, *modules) } end def reverse_order @@ -201,7 +195,7 @@ module ActiveRecord stashed_association_joins = joins.select {|j| j.is_a?(ActiveRecord::Associations::ClassMethods::JoinDependency::JoinAssociation)} - non_association_joins = (joins - association_joins - stashed_association_joins).reject {|j| j.blank?} + non_association_joins = (joins - association_joins - stashed_association_joins) custom_joins = custom_join_sql(*non_association_joins) join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, association_joins, custom_joins) |