diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-08-31 13:19:06 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2010-08-31 13:19:06 -0300 |
commit | 2431af1b7f731067cd01223b5e0fab3dc55ebea6 (patch) | |
tree | a4b6a11ebd69dd54d400b8373aecbf99fd9f48e2 | |
parent | 67a2b5ec1bf9e34df18763490e14089733e8c774 (diff) | |
download | rails-2431af1b7f731067cd01223b5e0fab3dc55ebea6.tar.gz rails-2431af1b7f731067cd01223b5e0fab3dc55ebea6.tar.bz2 rails-2431af1b7f731067cd01223b5e0fab3dc55ebea6.zip |
Don't test conditional in iteration if it is not present just clone it.
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index bb9cdaaefe..de7e5c7131 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -11,40 +11,40 @@ module ActiveRecord def includes(*args) args.reject! { |a| a.blank? } - clone.tap {|r| r.includes_values = (r.includes_values + args).flatten.uniq if args.present? } + args.present? ? clone.tap {|r| r.includes_values = (r.includes_values + args).flatten.uniq } : clone end def eager_load(*args) - clone.tap {|r| r.eager_load_values += args if args.present? } + args.present? ? clone.tap {|r| r.eager_load_values += args } : clone end def preload(*args) - clone.tap {|r| r.preload_values += args if args.present? } + args.present? ? clone.tap {|r| r.preload_values += args } : clone end def select(*args) if block_given? to_a.select {|*block_args| yield(*block_args) } else - clone.tap {|r| r.select_values += args if args.present? } + args.present? ? clone.tap {|r| r.select_values += args } : clone end end def group(*args) - clone.tap {|r| r.group_values += args.flatten if args.present? } + args.present? ? clone.tap {|r| r.group_values += args.flatten } : clone end def order(*args) - clone.tap {|r| r.order_values += args if args.present? } + args.present? ? clone.tap {|r| r.order_values += args } : clone end def reorder(*args) - clone.tap {|r| r.order_values = args if args.present? } + args.present? ? clone.tap {|r| r.order_values = args } : clone end def joins(*args) args.flatten! - clone.tap {|r| r.joins_values += args if args.present? } + args.present? ? clone.tap {|r| r.joins_values += args } : clone end def where(opts, *rest) @@ -56,7 +56,7 @@ module ActiveRecord def having(*args) value = build_where(*args) - clone.tap {|r| r.having_values += Array.wrap(value) if value.present? } + value.present? ? clone.tap {|r| r.having_values += Array.wrap(value) } : clone end def limit(value = true) |