diff options
Diffstat (limited to 'activerecord/lib/active_record/dynamic_scope_match.rb')
-rw-r--r-- | activerecord/lib/active_record/dynamic_scope_match.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/dynamic_scope_match.rb b/activerecord/lib/active_record/dynamic_scope_match.rb index a502155aac..6c043d29c4 100644 --- a/activerecord/lib/active_record/dynamic_scope_match.rb +++ b/activerecord/lib/active_record/dynamic_scope_match.rb @@ -7,9 +7,12 @@ module ActiveRecord # chain more <tt>scoped_by_* </tt> methods after the other. It acts like a named # scope except that it's dynamic. class DynamicScopeMatch + METHOD_PATTERN = /^scoped_by_([_a-zA-Z]\w*)$/ + def self.match(method) - return unless method.to_s =~ /^scoped_by_([_a-zA-Z]\w*)$/ - new(true, $1 && $1.split('_and_')) + if method.to_s =~ METHOD_PATTERN + new(true, $1 && $1.split('_and_')) + end end def initialize(scope, attribute_names) |