Permalink
Browse files

Better not mutate the given options Hash

  • Loading branch information...
1 parent ddee6f2 commit dabcfc4914d6f1828189e90db79ce651249a5a19 @amatsuda amatsuda committed Jul 10, 2013
Showing with 3 additions and 3 deletions.
  1. +3 −3 activesupport/lib/active_support/core_ext/string/filters.rb
@@ -41,15 +41,15 @@ def squish!
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
else
length_with_room_for_omission
end
- "#{self[0, stop]}#{options[:omission]}"
+ "#{self[0, stop]}#{omission}"
end
end

0 comments on commit dabcfc4

Please sign in to comment.