Method: Mongoid::Scopable::ClassMethods#scoped

Defined in:
lib/mongoid/scopable.rb

#scoped(options = nil) ⇒ Criteria

Note:

This will force the default scope to be applied.

Get a criteria for the document with normal scoping.

Examples:

Get the criteria.

Band.scoped(skip: 10)

Parameters:

  • options (Hash) (defaults to: nil)

    Query options for the criteria.

Options Hash (options):

  • :skip (Integer)

    Optional number of documents to skip.

  • :limit (Integer)

    Optional number of documents to limit.

  • :sort (Array)

    Optional sorting options.

Returns:

Since:

  • 3.0.0



170
171
172
# File 'lib/mongoid/scopable.rb', line 170

def scoped(options = nil)
  queryable.scoped(options)
end