aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/scoping
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-03-21 20:30:48 +0000
committerJon Leighton <j@jonathanleighton.com>2012-03-21 20:30:48 +0000
commitf6db31ec16e42ee7713029f7120f0b011d1ddc6c (patch)
tree774788986a44ea5793d5029b53b15cc60bb102f4 /activerecord/lib/active_record/scoping
parent884e5b755888591c9d45e8105267e6ce1f4ffc79 (diff)
downloadrails-f6db31ec16e42ee7713029f7120f0b011d1ddc6c.tar.gz
rails-f6db31ec16e42ee7713029f7120f0b011d1ddc6c.tar.bz2
rails-f6db31ec16e42ee7713029f7120f0b011d1ddc6c.zip
Remove valid_scope_name? check - use ruby
scope is syntactic sugar for defining a class method. Ruby allows redefining methods but emits a warning when run with -w. So let's not implement our own logic for this. Users should run with -w if they want to be warned about redefined methods.
Diffstat (limited to 'activerecord/lib/active_record/scoping')
-rw-r--r--activerecord/lib/active_record/scoping/named.rb12
1 files changed, 1 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/scoping/named.rb b/activerecord/lib/active_record/scoping/named.rb
index c7c3ee2b06..20c8e4b0f7 100644
--- a/activerecord/lib/active_record/scoping/named.rb
+++ b/activerecord/lib/active_record/scoping/named.rb
@@ -172,10 +172,9 @@ module ActiveRecord
# Article.featured.titles
def scope(name, scope_options = {})
- valid_scope_name?(name)
extension = Module.new(&Proc.new) if block_given?
- singleton_class.send(:redefine_method, name) do |*args|
+ singleton_class.send(:define_method, name) do |*args|
options = scope_options.respond_to?(:call) ? unscoped { scope_options.call(*args) } : scope_options
options = scoped.apply_finder_options(options) if options.is_a?(Hash)
@@ -184,15 +183,6 @@ module ActiveRecord
extension ? relation.extending(extension) : relation
end
end
-
- protected
-
- def valid_scope_name?(name)
- if respond_to?(name, true)
- logger.warn "Creating scope :#{name}. " \
- "Overwriting existing method #{self.name}.#{name}."
- end
- end
end
end
end