2016-06-20 12:52:54 -04:00
|
|
|
module Gitlab
|
|
|
|
module Timeless
|
|
|
|
def self.timeless(model, &block)
|
|
|
|
original_record_timestamps = model.record_timestamps
|
|
|
|
model.record_timestamps = false
|
|
|
|
|
|
|
|
if block.arity.abs == 1
|
|
|
|
block.call(model)
|
|
|
|
else
|
|
|
|
block.call
|
|
|
|
end
|
2018-01-11 11:34:01 -05:00
|
|
|
|
2016-06-20 12:52:54 -04:00
|
|
|
ensure
|
|
|
|
model.record_timestamps = original_record_timestamps
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|