~michaelforrest/use-case-mapper/trunk

« back to all changes in this revision

Viewing changes to vendor/rails/activerecord/lib/active_record/dynamic_scope_match.rb

  • Committer: Richard Lee (Canonical)
  • Date: 2010-10-15 15:17:58 UTC
  • mfrom: (190.1.3 use-case-mapper)
  • Revision ID: richard.lee@canonical.com-20101015151758-wcvmfxrexsongf9d
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
module ActiveRecord
2
 
  class DynamicScopeMatch
3
 
    def self.match(method)
4
 
      ds_match = self.new(method)
5
 
      ds_match.scope ? ds_match : nil
6
 
    end
7
 
 
8
 
    def initialize(method)
9
 
      @scope = true
10
 
      case method.to_s
11
 
      when /^scoped_by_([_a-zA-Z]\w*)$/
12
 
        names = $1
13
 
      else
14
 
        @scope = nil
15
 
      end
16
 
      @attribute_names = names && names.split('_and_')
17
 
    end
18
 
 
19
 
    attr_reader :scope, :attribute_names
20
 
 
21
 
    def scope?
22
 
      !@scope.nil?
23
 
    end
24
 
  end
25
 
end