Module: Mongoid::Paranoia::ClassMethods

Defined in:
lib/mongoid/paranoia.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#criteria(embedded = false, scoped = true) ⇒ Criteria

Override the default Criteria accessor to only get existing documents. Passes all arguments up to NamedScope.criteria

Examples:

Override the criteria.

Person.criteria

Parameters:

  • args (Array)

    The arguments.

Returns:

  • (Criteria)

    The paranoid compliant criteria.

Since:

  • 1.0.0



139
140
141
# File 'lib/mongoid/paranoia.rb', line 139

def criteria(embedded = false, scoped = true)
  scoped ? super.where(:deleted_at => nil) : super
end

#deletedCriteria

Find deleted documents

Examples:

Find deleted documents.

Person.deleted
Company.first.employees.deleted
Person.deleted.find("4c188dea7b17235a2a000001").first

Returns:

Since:

  • 1.0.0



153
154
155
# File 'lib/mongoid/paranoia.rb', line 153

def deleted
  where(:deleted_at.ne => nil)
end