Module: ActiveRecord::Timestamp::ClassMethods

Defined in:
activerecord/lib/active_record/timestamp.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#all_timestamp_attributes_in_modelObject


72
73
74
75
# File 'activerecord/lib/active_record/timestamp.rb', line 72

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


77
78
79
# File 'activerecord/lib/active_record/timestamp.rb', line 77

def current_time_from_proper_timezone
  connection.default_timezone == :utc ? Time.now.utc : Time.now
end

#timestamp_attributes_for_create_in_modelObject


62
63
64
65
# File 'activerecord/lib/active_record/timestamp.rb', line 62

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


67
68
69
70
# File 'activerecord/lib/active_record/timestamp.rb', line 67

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
# File 'activerecord/lib/active_record/timestamp.rb', line 56

def touch_attributes_with_time(*names, time: nil)
  attribute_names = timestamp_attributes_for_update_in_model
  attribute_names |= names.map(&:to_s)
  attribute_names.index_with(time || current_time_from_proper_timezone)
end