Skip to content
Browse files

Merge remote branch 'miloops/rails_master_fixes'

  • Loading branch information...
2 parents 7694b97 + c11eec8 commit dce0cfae8b3d060ac141fe73f124a2db14b17eac @lifo lifo committed
Showing with 26 additions and 15 deletions.
  1. +26 −15 activerecord/lib/active_record/relation/query_methods.rb
View
41 activerecord/lib/active_record/relation/query_methods.rb
@@ -11,52 +11,63 @@ module QueryMethods
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? }
+ if args.present?
+ args.flatten!
+ clone.tap {|r| r.joins_values += args }
+ else
+ clone
+ end
end
def where(opts, *rest)
- value = build_where(opts, rest)
- copy = clone
- copy.where_values += Array.wrap(value) if value
- copy
+ if opts.present? && value = build_where(opts, rest)
+ copy = clone
+ copy.where_values += Array.wrap(value)
+ copy
+ else
+ clone
+ end
end
def having(*args)
- value = build_where(*args)
- clone.tap {|r| r.having_values += Array.wrap(value) if value.present? }
+ if args.present?
+ value = build_where(*args)
+ clone.tap {|r| r.having_values += Array.wrap(value) }
+ else
+ clone
+ end
end
def limit(value)

0 comments on commit dce0cfa

Please sign in to comment.
Something went wrong with that request. Please try again.