Module: ActiveRecord::Timestamp::ClassMethods
- Defined in:
- lib/active_record/timestamp.rb
Overview
:nodoc:
Instance Method Summary collapse
- #all_timestamp_attributes_in_model ⇒ Object
- #current_time_from_proper_timezone ⇒ Object
- #timestamp_attributes_for_create_in_model ⇒ Object
- #timestamp_attributes_for_update_in_model ⇒ Object
- #touch_attributes_with_time(*names, time: nil) ⇒ Object
Instance Method Details
#all_timestamp_attributes_in_model ⇒ Object
74 75 76 77 |
# File 'lib/active_record/timestamp.rb', line 74 def @all_timestamp_attributes_in_model ||= ( + ).freeze end |
#current_time_from_proper_timezone ⇒ Object
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_model ⇒ Object
64 65 66 67 |
# File 'lib/active_record/timestamp.rb', line 64 def @timestamp_attributes_for_create_in_model ||= ( & column_names).freeze end |
#timestamp_attributes_for_update_in_model ⇒ Object
69 70 71 72 |
# File 'lib/active_record/timestamp.rb', line 69 def @timestamp_attributes_for_update_in_model ||= ( & 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 = attribute_names |= names attribute_names.index_with(time || current_time_from_proper_timezone) end |