aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/inflector/methods.rb
diff options
context:
space:
mode:
authorbrainopia <brainopia@evilmartians.com>2015-04-02 02:11:07 +0300
committerbrainopia <brainopia@evilmartians.com>2015-04-02 02:15:07 +0300
commit58d75fd8112d27c0f4bdd004e10b4f4e8b350595 (patch)
tree2708205fb412b55f1dea947da22aaed47c1fd485 /activesupport/lib/active_support/inflector/methods.rb
parentcdac52e124769909b6cb5fce2c4d00e09d21e059 (diff)
downloadrails-58d75fd8112d27c0f4bdd004e10b4f4e8b350595.tar.gz
rails-58d75fd8112d27c0f4bdd004e10b4f4e8b350595.tar.bz2
rails-58d75fd8112d27c0f4bdd004e10b4f4e8b350595.zip
Freeze static arguments for gsub
Diffstat (limited to 'activesupport/lib/active_support/inflector/methods.rb')
-rw-r--r--activesupport/lib/active_support/inflector/methods.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb
index 6c58009efc..a08c655d69 100644
--- a/activesupport/lib/active_support/inflector/methods.rb
+++ b/activesupport/lib/active_support/inflector/methods.rb
@@ -73,7 +73,7 @@ module ActiveSupport
string = string.sub(/^(?:#{inflections.acronym_regex}(?=\b|[A-Z_])|\w)/) { $&.downcase }
end
string.gsub!(/(?:_|(\/))([a-z\d]*)/i) { "#{$1}#{inflections.acronyms[$2] || $2.capitalize}" }
- string.gsub!('/', '::')
+ string.gsub!('/'.freeze, '::'.freeze)
string
end
@@ -90,7 +90,7 @@ module ActiveSupport
# camelize(underscore('SSLError')) # => "SslError"
def underscore(camel_cased_word)
return camel_cased_word unless camel_cased_word =~ /[A-Z-]|::/
- word = camel_cased_word.to_s.gsub('::', '/')
+ word = camel_cased_word.to_s.gsub('::'.freeze, '/'.freeze)
word.gsub!(/(?:(?<=([A-Za-z\d]))|\b)(#{inflections.acronym_regex})(?=\b|[^a-z])/) { "#{$1 && '_'}#{$2.downcase}" }
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')