aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/multibyte
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-10-20 16:02:31 -0600
committerSean Griffin <sean@seantheprogrammer.com>2015-10-20 16:05:16 -0600
commitb945de3662105abe330cad6e18962ccf7438150b (patch)
tree4651bcff93af8b47c56f25509125f1a6d5cbbeb3 /activesupport/lib/active_support/multibyte
parent09b46c7dbea6ac2ac09ba4a41fae0bf628a775f3 (diff)
downloadrails-b945de3662105abe330cad6e18962ccf7438150b.tar.gz
rails-b945de3662105abe330cad6e18962ccf7438150b.tar.bz2
rails-b945de3662105abe330cad6e18962ccf7438150b.zip
Update #20737 to address feedback
Given that this pull request affects a mutable value, we need to test for and document the affects on the receiver in this case. Additionally, this pull request was missing a CHANGELOG entry.
Diffstat (limited to 'activesupport/lib/active_support/multibyte')
-rw-r--r--activesupport/lib/active_support/multibyte/chars.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/multibyte/chars.rb b/activesupport/lib/active_support/multibyte/chars.rb
index a76692ec4b..707cf200b5 100644
--- a/activesupport/lib/active_support/multibyte/chars.rb
+++ b/activesupport/lib/active_support/multibyte/chars.rb
@@ -86,7 +86,8 @@ module ActiveSupport #:nodoc:
end
# Works like <tt>String#slice!</tt>, but returns an instance of
- # Chars, or nil if the string was not modified.
+ # Chars, or nil if the string was not modified. The string will not be
+ # modified if the range given is out of bounds
#
# string = 'Welcome'
# string.mb_chars.slice!(3) # => #<ActiveSupport::Multibyte::Chars:0x000000038109b8 @wrapped_string="c">
@@ -95,7 +96,9 @@ module ActiveSupport #:nodoc:
# string # => 'me'
def slice!(*args)
string_sliced = @wrapped_string.slice!(*args)
- string_sliced ? chars(string_sliced) : nil
+ if string_sliced
+ chars(string_sliced)
+ end
end
# Reverses all characters in the string.