diff options
author | José Valim <jose.valim@gmail.com> | 2010-06-26 22:37:12 +0200 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-26 22:37:24 +0200 |
commit | 5b91c97763f1183f131e46e51ed33129c6b1edcc (patch) | |
tree | 5c3fee0ac87452f74c1072cd41905ff4ffb65361 /activerecord/lib | |
parent | 926ca9c102db5034d4eb1ab0f915ea643145e284 (diff) | |
download | rails-5b91c97763f1183f131e46e51ed33129c6b1edcc.tar.gz rails-5b91c97763f1183f131e46e51ed33129c6b1edcc.tar.bz2 rails-5b91c97763f1183f131e46e51ed33129c6b1edcc.zip |
Create a little bit less objects in ARel.
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index ff5bce9d8b..caa55929f4 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -12,18 +12,20 @@ module ActiveRecord next if [:where, :having, :select].include?(query_method) class_eval <<-CEVAL, __FILE__, __LINE__ + 1 def #{query_method}(*args) + args.flatten! + args.reject! { |a| a.blank? } new_relation = clone - value = Array.wrap(args.flatten).reject {|x| x.blank? } - new_relation.#{query_method}_values += value if value.present? + new_relation.#{query_method}_values += args if args.present? new_relation end CEVAL end def reorder(*args) + args.flatten! + args.reject! { |a| a.blank? } new_relation = clone - value = Array.wrap(args.flatten).reject {|x| x.blank? } - new_relation.order_values = value if value.present? + new_relation.order_values = args if args.present? new_relation end @@ -31,9 +33,10 @@ module ActiveRecord if block_given? to_a.select { |*block_args| yield(*block_args) } else + args.flatten! + args.reject! { |a| a.blank? } new_relation = clone - value = Array.wrap(args.flatten).reject {|x| x.blank? } - new_relation.select_values += value if value.present? + new_relation.select_values += args if args.present? new_relation end end |