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.

Methods
M
N
Attributes
[R] attribute_names
[R] scope
[R] scope?
Class Public methods
match(method)
# File activerecord/lib/active_record/dynamic_scope_match.rb, line 10
def self.match(method)
  return unless method.to_s =~ %r^scoped_by_([_a-zA-Z]\w*)$/
  new(true, $1 && $1.split('_and_'))
end
new(scope, attribute_names)
# File activerecord/lib/active_record/dynamic_scope_match.rb, line 15
def initialize(scope, attribute_names)
  @scope           = scope
  @attribute_names = attribute_names
end