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

#clear_timeless_optiontrue

Clears out the timeless option.

Examples:

Clear the timeless option.

document.clear_timeless_option

Returns:

  • (true)

    True.

Since:

  • 3.1.4



23
24
25
# File 'lib/mongoid/timestamps/timeless.rb', line 23

def clear_timeless_option
  self.class.timestamping = true
end

#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



35
36
37
38
# File 'lib/mongoid/timestamps/timeless.rb', line 35

def timeless
  self.class.timestamping = false
  self
end