Permalink
Browse files

avoid multiple hash lookups

  • Loading branch information...
tenderlove committed Aug 11, 2010
1 parent 5352a89 commit ff760dd6ceee4414e54afdb346c322dee6280edc
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/relation/spawn_methods.rb
@@ -80,10 +80,14 @@ def apply_finder_options(options)
options.assert_valid_keys(VALID_FIND_OPTIONS)
[:joins, :select, :group, :having, :limit, :offset, :from, :lock, :readonly].each do |finder|
relation = relation.send(finder, options[finder]) if options.has_key?(finder)
[:joins, :select, :group, :having, :limit, :offset, :from, :lock].each do |finder|
if value = options[finder]
relation = relation.send(finder, value)
end
end
relation = relation.readonly(options[:readonly]) if options.key? :readonly
# Give precedence to newly-applied orders and groups to play nicely with with_scope
[:group, :order].each do |finder|
relation.send("#{finder}_values=", Array.wrap(options[finder]) + relation.send("#{finder}_values")) if options.has_key?(finder)

0 comments on commit ff760dd

Please sign in to comment.