From 82820ef53ddedaf0f5f20ba5ccd5466c1408c7de Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Sun, 8 Jun 2014 18:00:21 -0600 Subject: Refactor determination of max updated timestamp `[].max # => nil` --- activerecord/lib/active_record/timestamp.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'activerecord') 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 -- cgit v1.2.3