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
# File 'lib/mongoid/timestamps/timeless.rb', line 18

def timeless
  tap { Threaded.timeless = true }
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



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

def timestamping?
  Threaded.timestamping?
end