Module: Gitlab::Timeless

Defined in:
lib/gitlab/timeless.rb

Class Method Summary collapse

Class Method Details

.timeless(model, &block) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/gitlab/timeless.rb', line 5

def self.timeless(model, &block)
  original_record_timestamps = model.record_timestamps
  model.record_timestamps = false

  # negative arity means arguments are optional
  if block.arity == 1 || block.arity < 0
    block.call(model)
  else
    block.call
  end

ensure
  model.record_timestamps = original_record_timestamps
end