Skip to content
Browse files

refactoring build_where

Signed-off-by: wycats <wycats@gmail.com>
  • Loading branch information...
1 parent 028e54c commit 45c36ea0961d015bf040043c7ab2ac2069d3b92f @tenderlove tenderlove committed with wycats Mar 6, 2010
Showing with 7 additions and 7 deletions.
  1. +7 −7 activerecord/lib/active_record/relation/query_methods.rb
View
14 activerecord/lib/active_record/relation/query_methods.rb
@@ -184,16 +184,16 @@ def build_where(*args)
builder = PredicateBuilder.new(table.engine)
- conditions = if [String, Array].include?(args.first.class)
- @klass.send(:sanitize_sql, args.size > 1 ? args : args.first)
- elsif args.first.is_a?(Hash)
- attributes = @klass.send(:expand_hash_conditions_for_aggregates, args.first)
+ opts = args.first
+ case opts
+ when String, Array
+ @klass.send(:sanitize_sql, args.size > 1 ? args : opts)
+ when Hash
+ attributes = @klass.send(:expand_hash_conditions_for_aggregates, opts)
builder.build_from_hash(attributes, table)
else
- args.first
+ opts
end
-
- conditions
end
private

0 comments on commit 45c36ea

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