Skip to content

Commit 4c0cee8

Browse files
nobubyroot
authored andcommitted
Reduce captures in ActiveSupport::Inflector#underscore
1 parent d36fb65 commit 4c0cee8

File tree

1 file changed

+1
-1
lines changed
  • activesupport/lib/active_support/inflector

1 file changed

+1
-1
lines changed

activesupport/lib/active_support/inflector/methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def underscore(camel_cased_word)
9898
return camel_cased_word.to_s.dup unless /[A-Z-]|::/.match?(camel_cased_word)
9999
word = camel_cased_word.to_s.gsub("::", "/")
100100
word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" }
101-
word.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" }
101+
word.gsub!(/(?<=[A-Z])(?=[A-Z][a-z])|(?<=[a-z\d])(?=[A-Z])/, "_")
102102
word.tr!("-", "_")
103103
word.downcase!
104104
word

0 commit comments

Comments
 (0)