Module: Mongoid::Safe

Included in:
Persistence::Atomic::Operation, Persistence::Command
Defined in:
lib/mongoid/safe.rb

Overview

Contains behaviour for determining if Mongoid is in safe mode.

Instance Method Summary collapse

Instance Method Details

#safe_mode?(options) ⇒ true, false

Determine based on configuration if we are persisting in safe mode or not.

The query option will always override the global configuration.

Examples:

Are we in safe mode?

document.safe_mode?(:safe => true)

Parameters:

  • options (Hash)

    Persistence options.

Returns:

  • (true, false)

    True if in safe mode, false if not.



18
19
20
21
# File 'lib/mongoid/safe.rb', line 18

def safe_mode?(options)
  safe = options[:safe]
  safe.nil? ? Mongoid.persist_in_safe_mode : safe
end