123456789_123456789_123456789_123456789_123456789_

Module: ActiveRecord::Timestamp::ClassMethods

Do not use. This module is for internal use only.
Relationships & Source Files
Defined in: activerecord/lib/active_record/timestamp.rb

Instance Method Summary

Instance Method Details

#all_timestamp_attributes_in_model

[ GitHub ]

  
# File 'activerecord/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_timezone

[ GitHub ]

  
# File 'activerecord/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

#reload_schema_from_cache(recursive = true) (protected)

[ GitHub ]

  
# File 'activerecord/lib/active_record/timestamp.rb', line 84

def reload_schema_from_cache(recursive = true)
  @timestamp_attributes_for_create_in_model = nil
  @timestamp_attributes_for_update_in_model = nil
  @all_timestamp_attributes_in_model = nil
  super
end

#timestamp_attributes_for_create (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/timestamp.rb', line 92

def timestamp_attributes_for_create
  ["created_at", "created_on"].map! { |name| attribute_aliases[name] || name }
end

#timestamp_attributes_for_create_in_model

[ GitHub ]

  
# File 'activerecord/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 (private)

[ GitHub ]

  
# File 'activerecord/lib/active_record/timestamp.rb', line 96

def timestamp_attributes_for_update
  ["updated_at", "updated_on"].map! { |name| attribute_aliases[name] || name }
end

#timestamp_attributes_for_update_in_model

[ GitHub ]

  
# File 'activerecord/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)

[ GitHub ]

  
# File 'activerecord/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