Module: Mongoid::Timestamps::Timeless

Extended by:
ActiveSupport::Concern, Forwardable
Defined in:
build/mongoid-8.1/lib/mongoid/timestamps/timeless.rb

Overview

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.timeless_tableObject



44
45
46
# File 'build/mongoid-8.1/lib/mongoid/timestamps/timeless.rb', line 44

def timeless_table
  Thread.current['[mongoid]:timeless'] ||= Hash.new
end

Instance Method Details

#clear_timeless_optiontrue

Clears out the timeless option.

Examples:

Clear the timeless option.

document.clear_timeless_option

Returns:

  • (true)

    True.



17
18
19
20
21
22
23
24
# File 'build/mongoid-8.1/lib/mongoid/timestamps/timeless.rb', line 17

def clear_timeless_option
  if self.persisted?
    self.class.clear_timeless_option_on_update
  else
    self.class.clear_timeless_option
  end
  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.



32
33
34
35
# File 'build/mongoid-8.1/lib/mongoid/timestamps/timeless.rb', line 32

def timeless
  self.class.timeless
  self
end

#timeless?Boolean

Returns:



37
38
39
# File 'build/mongoid-8.1/lib/mongoid/timestamps/timeless.rb', line 37

def timeless?
  self.class.timeless?
end