Method: Mongoid::Scopable::ClassMethods#without_default_scope

Defined in:
lib/mongoid/scopable.rb

#without_default_scopeObject

Execute the block without applying the default scope.

Examples:

Execute without the default scope.

Band.without_default_scope do
  Band.where(name: "Depeche Mode")
end

Returns:

  • (Object)

    The result of the block.



227
228
229
230
231
232
# File 'lib/mongoid/scopable.rb', line 227

def without_default_scope
  Threaded.begin_without_default_scope(self)
  yield
ensure
  Threaded.exit_without_default_scope(self)
end