aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2013-07-10 23:09:33 +0900
committerAkira Matsuda <ronnie@dio.jp>2013-07-10 23:31:02 +0900
commitdabcfc4914d6f1828189e90db79ce651249a5a19 (patch)
tree572a394f0b68ed66255560cce151da799890ab86 /activesupport
parentddee6f24a53aa6b8bb4685122ff694000e4d4743 (diff)
downloadrails-dabcfc4914d6f1828189e90db79ce651249a5a19.tar.gz
rails-dabcfc4914d6f1828189e90db79ce651249a5a19.tar.bz2
rails-dabcfc4914d6f1828189e90db79ce651249a5a19.zip
Better not mutate the given options Hash
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/string/filters.rb6
1 files 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