aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/timestamp.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-06-08 18:00:21 -0600
committerSean Griffin <sean@thoughtbot.com>2014-06-09 08:31:14 -0600
commit82820ef53ddedaf0f5f20ba5ccd5466c1408c7de (patch)
treef25346df9c72ab10900009264c20b3ec35252ba2 /activerecord/lib/active_record/timestamp.rb
parent97ca81385eeda66925110a5d4d8c288977aac6eb (diff)
downloadrails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.tar.gz
rails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.tar.bz2
rails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.zip
Refactor determination of max updated timestamp
`[].max # => nil`
Diffstat (limited to 'activerecord/lib/active_record/timestamp.rb')
-rw-r--r--activerecord/lib/active_record/timestamp.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/timestamp.rb b/activerecord/lib/active_record/timestamp.rb
index 6c30ccab72..e2e37e7c00 100644
--- a/activerecord/lib/active_record/timestamp.rb
+++ b/activerecord/lib/active_record/timestamp.rb
@@ -99,9 +99,11 @@ module ActiveRecord
end
def max_updated_column_timestamp(timestamp_names = timestamp_attributes_for_update)
- if (timestamps = timestamp_names.map { |attr| self[attr] }.compact).present?
- timestamps.map { |ts| ts.to_time }.max
- end
+ timestamp_names
+ .map { |attr| self[attr] }
+ .compact
+ .map(&:to_time)
+ .max
end
def current_time_from_proper_timezone