From dabcfc4914d6f1828189e90db79ce651249a5a19 Mon Sep 17 00:00:00 2001 From: Akira Matsuda Date: Wed, 10 Jul 2013 23:09:33 +0900 Subject: Better not mutate the given options Hash --- activesupport/lib/active_support/core_ext/string/filters.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/string/filters.rb b/activesupport/lib/active_support/core_ext/string/filters.rb index 91d91e10e1..a4cacaf789 100644 --- a/activesupport/lib/active_support/core_ext/string/filters.rb +++ b/activesupport/lib/active_support/core_ext/string/filters.rb @@ -41,8 +41,8 @@ class String def truncate(truncate_at, options = {}) return dup unless length > truncate_at - options[:omission] ||= '...' - length_with_room_for_omission = truncate_at - options[:omission].length + omission = options[:omission] || '...' + length_with_room_for_omission = truncate_at - omission.length stop = \ if options[:separator] rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission @@ -50,6 +50,6 @@ class String length_with_room_for_omission end - "#{self[0, stop]}#{options[:omission]}" + "#{self[0, stop]}#{omission}" end end -- cgit v1.2.3