Is there any documentation for how the match command converts the “:to”
argument to a class and method name?
If I have
match ‘’, to: ‘#’,
via: :get
How does it go from to , and
more importantly, how do I go in the reverse direction?
I can probably figure this out via trial-and-error, but I’d like to see
docs if there are some, or contribute some docs if not.
This is not really documented anywhere, and tracing through the source
is
difficult. Within Rails the string inflector methods #classify and
#underscore are used to go between snake-case names and camel-cased
class
and module names.
The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.
"MyFoo".underscore # => "my_foo"
"MyApp::Foo".underscore # => "my_app/foo"
The Inflector transforms words from singular to plural, class names to table names, modularized class names to ones without, and class names to foreign keys.
"my_foo".classify # => "MyFoo"
"my_app/foo".classify # => "MyApp::Foo"