diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-08 18:00:21 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-09 08:31:14 -0600 |
commit | 82820ef53ddedaf0f5f20ba5ccd5466c1408c7de (patch) | |
tree | f25346df9c72ab10900009264c20b3ec35252ba2 /activerecord/lib | |
parent | 97ca81385eeda66925110a5d4d8c288977aac6eb (diff) | |
download | rails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.tar.gz rails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.tar.bz2 rails-82820ef53ddedaf0f5f20ba5ccd5466c1408c7de.zip |
Refactor determination of max updated timestamp
`[].max # => nil`
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/timestamp.rb | 8 |
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 |