Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

avoid multiple hash lookups

  • Loading branch information...
commit ff760dd6ceee4414e54afdb346c322dee6280edc 1 parent 5352a89
@tenderlove tenderlove authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 activerecord/lib/active_record/relation/spawn_methods.rb
View
8 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)
Please sign in to comment.
Something went wrong with that request. Please try again.