module ActiveRecord::Timestamp
def _create_record
def _create_record if record_timestamps current_time = current_time_from_proper_timezone all_timestamp_attributes_in_model.each do |column| _write_attribute(column, current_time) unless _read_attribute(column) end end super end
def _update_record
def _update_record if @_touch_record && should_record_timestamps? current_time = current_time_from_proper_timezone timestamp_attributes_for_update_in_model.each do |column| next if will_save_change_to_attribute?(column) _write_attribute(column, current_time) end end super end
def all_timestamp_attributes_in_model
def all_timestamp_attributes_in_model self.class.all_timestamp_attributes_in_model end
def clear_timestamp_attributes
def clear_timestamp_attributes all_timestamp_attributes_in_model.each do |attribute_name| self[attribute_name] = nil clear_attribute_change(attribute_name) end end
def create_or_update(touch: true, **)
def create_or_update(touch: true, **) @_touch_record = touch super end
def current_time_from_proper_timezone
def current_time_from_proper_timezone self.class.current_time_from_proper_timezone end
def initialize_dup(other) # :nodoc:
def initialize_dup(other) # :nodoc: super clear_timestamp_attributes end
def max_updated_column_timestamp
def max_updated_column_timestamp timestamp_attributes_for_update_in_model .filter_map { |attr| self[attr]&.to_time } .max end
def should_record_timestamps?
def should_record_timestamps? record_timestamps && (!partial_updates? || has_changes_to_save?) end
def timestamp_attributes_for_create_in_model
def timestamp_attributes_for_create_in_model self.class.timestamp_attributes_for_create_in_model end
def timestamp_attributes_for_update_in_model
def timestamp_attributes_for_update_in_model self.class.timestamp_attributes_for_update_in_model end