Method: Mongoid::Criteria::Scopable#with_default_scope
- Defined in:
- lib/mongoid/criteria/scopable.rb
#with_default_scope ⇒ Criteria
Get the criteria with the default scope applied, if the default scope is able to be applied. Cases in which it cannot are: If we are in an unscoped block, if the criteria is already forced unscoped, or the default scope has already been applied.
152 153 154 155 156 157 158 |
# File 'lib/mongoid/criteria/scopable.rb', line 152 def with_default_scope crit = clone if klass.default_scopable? && !unscoped? && !scoped? crit.apply_default_scope end crit end |