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.
# 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
# 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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.