class Zeitwerk::Inflector
def camelize(basename, _abspath)
Takes into account hard-coded mappings configured with `inflect`.
inflector.camelize("api", ...) # => "Api"
inflector.camelize("users_controller", ...) # => "UsersController"
inflector.camelize("post", ...) # => "Post"
inflector = Zeitwerk::Inflector.new
Very basic snake case -> camel case conversion.
def camelize(basename, _abspath) overrides[basename] || basename.split('_').each(&:capitalize!).join end
def inflect(inflections)
inflector.camelize("users_controller", abspath) # => "UsersController"
inflector.camelize("mysql_adapter", abspath) # => "MySQLAdapter"
inflector.camelize("html_parser", abspath) # => "HTMLParser"
)
"mysql_adapter" => "MySQLAdapter"
"html_parser" => "HTMLParser",
inflector.inflect(
inflector = Zeitwerk::Inflector.new
Configures hard-coded inflections:
def inflect(inflections) overrides.merge!(inflections) end
def overrides
inflection logic.
Hard-coded basename to constant name user maps that override the default
def overrides @overrides ||= {} end