123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Timestamps::Timeless

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Forwardable, ActiveSupport::Concern
Defined in: lib/mongoid/timestamps/timeless.rb

Overview

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

Class Method Summary

  • .timeless_table ⇒ Hash Internal use only Internal use only

    Returns the in-memory thread cache of classes for which to skip timestamping.

Instance Attribute Summary

Instance Method Summary

Class Method Details

.timeless_tableHash

This method is for internal use only.

Returns the in-memory thread cache of classes for which to skip timestamping.

Returns:

  • (Hash)

    The timeless table.

[ GitHub ]

  
# File 'lib/mongoid/timestamps/timeless.rb', line 55

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

Instance Attribute Details

#timelessDocument (readonly)

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.

[ GitHub ]

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

def timeless
  self.class.timeless
  self
end

#timeless?true | false (readonly)

Returns whether the document should skip timestamping.

Returns:

  • (true | false)

    Whether the document should skip timestamping.

[ GitHub ]

  
# File 'lib/mongoid/timestamps/timeless.rb', line 42

def timeless?
  self.class.timeless?
end

Instance Method Details

#clear_timeless_optiontrue

Clears out the timeless option.

Examples:

Clear the timeless option.

document.clear_timeless_option

Returns:

  • (true)

    True.

[ GitHub ]

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

def clear_timeless_option
  if self.persisted?
    self.class.clear_timeless_option_on_update
  else
    self.class.clear_timeless_option
  end
  true
end