BigW Consortium Gitlab

timeless.rb 351 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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
    ensure
      model.record_timestamps = original_record_timestamps
    end
  end
end