Method: Mongoid::Scopable::ClassMethods#scope
- Defined in:
- lib/mongoid/scopable.rb
#scope(name, value, &block) ⇒ Object
Create a scope that can be accessed from the class level or chained to criteria by the provided name.
142 143 144 145 146 147 148 149 150 151 |
# File 'lib/mongoid/scopable.rb', line 142 def scope(name, value, &block) normalized = name.to_sym check_scope_validity(value) check_scope_name(normalized) _declared_scopes[normalized] = { scope: value, extension: Module.new(&block) } define_scope_method(normalized) end |