Module: ActiveRecord::Timestamp::ClassMethods

Defined in:
lib/active_record/timestamp.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#all_timestamp_attributes_in_modelObject



74
75
76
77
# File 'lib/active_record/timestamp.rb', line 74

def all_timestamp_attributes_in_model
  @all_timestamp_attributes_in_model ||=
    (timestamp_attributes_for_create_in_model + timestamp_attributes_for_update_in_model).freeze
end

#current_time_from_proper_timezoneObject



79
80
81
# File 'lib/active_record/timestamp.rb', line 79

def current_time_from_proper_timezone
  with_connection { |c| c.default_timezone == :utc ? Time.now.utc : Time.now }
end

#timestamp_attributes_for_create_in_modelObject



64
65
66
67
# File 'lib/active_record/timestamp.rb', line 64

def timestamp_attributes_for_create_in_model
  @timestamp_attributes_for_create_in_model ||=
    (timestamp_attributes_for_create & column_names).freeze
end

#timestamp_attributes_for_update_in_modelObject



69
70
71
72
# File 'lib/active_record/timestamp.rb', line 69

def timestamp_attributes_for_update_in_model
  @timestamp_attributes_for_update_in_model ||=
    (timestamp_attributes_for_update & column_names).freeze
end

#touch_attributes_with_time(*names, time: nil) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/active_record/timestamp.rb', line 56

def touch_attributes_with_time(*names, time: nil)
  names = names.map(&:to_s)
  names = names.map { |name| attribute_aliases[name] || name }
  attribute_names = timestamp_attributes_for_update_in_model
  attribute_names |= names
  attribute_names.index_with(time || current_time_from_proper_timezone)
end