Parent

Files

Class Index [+]

Quicksearch

ActiveRecord::DynamicScopeMatch

Active Record Dynamic Scope Match

Provides dynamic attribute-based scopes such as scoped_by_price(4.99) if, for example, the Product has an attribute with that name. You can chain more scoped_by_* methods after the other. It acts like a named scope except that it’s dynamic.

Attributes

scope[R]
attribute_names[R]

Public Class Methods

match(method) click to toggle source
    # File lib/active_record/dynamic_scope_match.rb, line 10
10:     def self.match(method)
11:       ds_match = self.new(method)
12:       ds_match.scope ? ds_match : nil
13:     end
new(method) click to toggle source
    # File lib/active_record/dynamic_scope_match.rb, line 15
15:     def initialize(method)
16:       @scope = true
17:       case method.to_s
18:       when /^scoped_by_([_a-zA-Z]\w*)$/
19:         names = $1
20:       else
21:         @scope = nil
22:       end
23:       @attribute_names = names && names.split('_and_')
24:     end

Public Instance Methods

scope?() click to toggle source
    # File lib/active_record/dynamic_scope_match.rb, line 28
28:     def scope?
29:       !@scope.nil?
30:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.