module ActiveSupport::Inflector
def underscore(camel_cased_word)
Experimental RBS support (using type sampling data from the type_fusion
project).
def underscore: (String camel_cased_word) -> untyped
This signature was generated using 1 sample from 1 application.
#camelize, though there are cases where that does not hold:
As a rule of thumb you can think of +underscore+ as the inverse of
underscore('ActiveModel::Errors') # => "active_model/errors"
underscore('ActiveModel') # => "active_model"
Changes '::' to '/' to convert namespaces to paths.
Makes an underscored, lowercase form from the expression in the string.
def underscore(camel_cased_word) return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word) word = camel_cased_word.to_s.gsub("::", "/") word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" } word.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" } word.tr!("-", "_") word.downcase! word end