aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector
diff options
context:
space:
mode:
authorKevin McPhillips <github@kevinmcphillips.ca>2017-01-16 13:49:44 -0500
committerKevin McPhillips <github@kevinmcphillips.ca>2017-01-16 14:40:41 -0500
commitf90a08c193d4ec8267f4409b7a670c2b53e0621d (patch)
tree1fd8388950d3bc6c52a802e7ebb0888bba2d0ec3 /activesupport/lib/active_support/inflector
parentc8e92f174d9190fe4cb38199bc2e59d62ace0003 (diff)
downloadrails-f90a08c193d4ec8267f4409b7a670c2b53e0621d.tar.gz
rails-f90a08c193d4ec8267f4409b7a670c2b53e0621d.tar.bz2
rails-f90a08c193d4ec8267f4409b7a670c2b53e0621d.zip
Raise ArgumentError if attempting to transliterate anything that is not a string
Diffstat (limited to 'activesupport/lib/active_support/inflector')
-rw-r--r--activesupport/lib/active_support/inflector/transliterate.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb
index 3e78986e8e..de6dd2720b 100644
--- a/activesupport/lib/active_support/inflector/transliterate.rb
+++ b/activesupport/lib/active_support/inflector/transliterate.rb
@@ -57,6 +57,8 @@ module ActiveSupport
# transliterate('Jürgen')
# # => "Juergen"
def transliterate(string, replacement = "?".freeze)
+ raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String)
+
I18n.transliterate(ActiveSupport::Multibyte::Unicode.normalize(
ActiveSupport::Multibyte::Unicode.tidy_bytes(string), :c),
replacement: replacement)