Module: Mongoid::Timestamps::Timeless::ClassMethods

Defined in:
lib/mongoid/timestamps/timeless.rb

Instance Method Summary collapse

Instance Method Details

#clear_timeless_optionObject



67
68
69
70
71
72
73
# File 'lib/mongoid/timestamps/timeless.rb', line 67

def clear_timeless_option
  if counter = Timeless[name]
    counter -= 1
    Timeless[name] = (counter == 0) ? nil : counter
  end
  true
end

#timelessClass

Begin an execution that should skip timestamping.

Examples:

Create a document but don’t timestamp.

Person.timeless.create(:title => "Sir")

Returns:

  • (Class)

    The class this was called on.

Since:

  • 2.3.0



59
60
61
62
63
64
65
# File 'lib/mongoid/timestamps/timeless.rb', line 59

def timeless
  counter = 0
  counter += 1 if self < Mongoid::Timestamps::Created
  counter += 1 if self < Mongoid::Timestamps::Updated
  Timeless[name] = counter
  self
end

#timeless?Boolean

Returns:



75
76
77
# File 'lib/mongoid/timestamps/timeless.rb', line 75

def timeless?
  !!Timeless[name]
end