diff options
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/dynamic_scope_match.rb | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/activerecord/lib/active_record/dynamic_scope_match.rb b/activerecord/lib/active_record/dynamic_scope_match.rb index 61c3ea0e7f..4e51df9e71 100644 --- a/activerecord/lib/active_record/dynamic_scope_match.rb +++ b/activerecord/lib/active_record/dynamic_scope_match.rb @@ -8,25 +8,21 @@ module ActiveRecord # scope except that it's dynamic. class DynamicScopeMatch def self.match(method) - ds_match = self.new(method) - ds_match.scope ? ds_match : nil + ds_match = new(method) + ds_match.scope && ds_match end def initialize(method) - @scope = true - case method.to_s - when /^scoped_by_([_a-zA-Z]\w*)$/ + @scope = nil + if method.to_s =~ /^scoped_by_([_a-zA-Z]\w*)$/ names = $1 - else - @scope = nil + @scope = true end + @attribute_names = names && names.split('_and_') end attr_reader :scope, :attribute_names - - def scope? - !@scope.nil? - end + alias :scope? :scope end end |