From b9e7c676ca13e286a371dc1b4996d2c15c0461e8 Mon Sep 17 00:00:00 2001 From: Eugene Kenny Date: Sun, 17 Dec 2017 00:49:02 +0000 Subject: Don't include ellipsis in truncated digest output Using `truncate` to limit the length of the digest has the unwanted side effect of adding an ellipsis when the input is longer than the limit. Also: - Don't instantiate a new object for every digest - Rename the configuration option to `hash_digest_class` - Update the CHANGELOG entry to describe how to use the feature --- activesupport/lib/active_support/digest.rb | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'activesupport/lib/active_support/digest.rb') diff --git a/activesupport/lib/active_support/digest.rb b/activesupport/lib/active_support/digest.rb index d77eeb072b..fba10fbdcf 100644 --- a/activesupport/lib/active_support/digest.rb +++ b/activesupport/lib/active_support/digest.rb @@ -13,16 +13,8 @@ module ActiveSupport end def hexdigest(arg) - new.hexdigest(arg) + hash_digest_class.hexdigest(arg)[0...32] end end - - def initialize(digest_class: nil) - @digest_class = digest_class || self.class.hash_digest_class - end - - def hexdigest(arg) - @digest_class.hexdigest(arg).truncate(32) - end end end -- cgit v1.2.3