Module: Mongoid::Timestamps::Timeless

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

Overview

This module adds behaviour for turning off timestamping in single or multiple calls.

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#timelessDocument

Begin an execution that should skip timestamping.

Examples:

Save a document but don’t timestamp.

person.timeless.save

Returns:

  • (Document)

    The document this was called on.

Since:

  • 2.3.0



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

def timeless
  Threaded.timeless = true
  self
end

#timestamping?true, false

Are we currently timestamping?

Examples:

Should timestamps be applied?

person.timestamping?

Returns:

  • (true, false)

    If the current thread is timestamping.

Since:

  • 2.3.0



31
32
33
# File 'lib/mongoid/timestamps/timeless.rb', line 31

def timestamping?
  Threaded.timestamping?
end