aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-04-22 09:22:43 +0200
committerJon Leighton <j@jonathanleighton.com>2012-04-25 15:45:05 +0100
commitf3fce59d13ddf89b79d4819b3290404ba792d049 (patch)
tree8688ed89d9db6602e0cce150acd049a497f3a8f4 /activerecord
parent408437334bcb5df8d8daf7b60c13d496222954d2 (diff)
downloadrails-f3fce59d13ddf89b79d4819b3290404ba792d049.tar.gz
rails-f3fce59d13ddf89b79d4819b3290404ba792d049.tar.bz2
rails-f3fce59d13ddf89b79d4819b3290404ba792d049.zip
extract to active_record_deprecated_finders
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/scoping/default.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index c887a106ef..db833fc7f1 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -87,10 +87,10 @@ module ActiveRecord
# # Should return a scope, you can call 'super' here etc.
# end
# end
- def default_scope(scope = {})
+ def default_scope(scope = nil)
scope = Proc.new if block_given?
- if scope.is_a?(Relation) || !scope.is_a?(Hash) && !scope.respond_to?(:call)
+ if scope.is_a?(Relation) || !scope.respond_to?(:call)
ActiveSupport::Deprecation.warn(
"Calling #default_scope without a block is deprecated. For example instead " \
"of `default_scope where(color: 'red')`, please use " \
@@ -103,14 +103,13 @@ module ActiveRecord
end
def build_default_scope #:nodoc:
- if method(:default_scope).owner != ActiveRecord::Scoping::Default::ClassMethods
+ if !Base.is_a?(method(:default_scope).owner)
+ # The user has defined their own default scope method, so call that
evaluate_default_scope { default_scope }
elsif default_scopes.any?
evaluate_default_scope do
default_scopes.inject(relation) do |default_scope, scope|
- if scope.is_a?(Hash)
- default_scope.apply_finder_options(scope)
- elsif !scope.is_a?(Relation) && scope.respond_to?(:call)
+ if !scope.is_a?(Relation) && scope.respond_to?(:call)
default_scope.merge(unscoped { scope.call })
else
default_scope.merge(scope)