Module: Mongoid::Safety

Extended by:
ActiveSupport::Concern
Included in:
Components
Defined in:
lib/mongoid/safety.rb

Overview

The Safety module is used to provide a DSL to execute database operations in safe mode on a per query basis, either from the Document class level or instance level.

Defined Under Namespace

Modules: ClassMethods Classes: Proxy

Instance Method Summary collapse

Instance Method Details

#safely(safety = true) ⇒ Proxy

Execute the following class-level persistence operation in safe mode.

Examples:

Upsert in safe mode.

person.safely.upsert

Destroy in safe mode with w and fsync options.

person.safely(:w => 2, :fsync => true).destroy

Parameters:

  • options (Hash)

    The safe mode options.

Returns:

  • (Proxy)

    The safety proxy.



26
27
28
# File 'lib/mongoid/safety.rb', line 26

def safely(safety = true)
  Proxy.new(self, safety)
end