Skip to content

Commit

Permalink
move apply_finder_options to active_record_deprecated_finders
Browse files Browse the repository at this point in the history
  • Loading branch information
jonleighton committed Apr 12, 2012
1 parent dd2c9b9 commit eda65f3
Showing 1 changed file with 0 additions and 22 deletions.
22 changes: 0 additions & 22 deletions activerecord/lib/active_record/relation/spawn_methods.rb
Expand Up @@ -128,27 +128,5 @@ def only(*onlies)
result
end

VALID_FIND_OPTIONS = [ :conditions, :include, :joins, :limit, :offset, :extend, :references,
:order, :select, :readonly, :group, :having, :from, :lock ]

def apply_finder_options(options)
relation = clone
return relation unless options

options.assert_valid_keys(VALID_FIND_OPTIONS)
finders = options.dup
finders.delete_if { |key, value| value.nil? && key != :limit }

((VALID_FIND_OPTIONS - [:conditions, :include, :extend]) & finders.keys).each do |finder|
relation = relation.send(finder, finders[finder])
end

relation = relation.where(finders[:conditions]) if options.has_key?(:conditions)
relation = relation.includes(finders[:include]) if options.has_key?(:include)
relation = relation.extending(finders[:extend]) if options.has_key?(:extend)

relation
end

end
end

0 comments on commit eda65f3

Please sign in to comment.