[Nitro] [PATCH][BUGFIX] Camel cases in class names are not handled correctly

zimba.tm zimba.tm at gmail.com
Thu Apr 6 03:01:18 EDT 2006

On Thursday 06 April 2006 00:21, Bryan Soto wrote:
> My solution was merely to generate the names in a consistent way. Two
> different sections of code were arriving at a name in two different
> ways. I chose to copy the way the field name was being created. :)
> >   "#{klass.to_s.demodulize.underscore.downcase}_oid"
> We really need to structure things better. There should be only one
> place names are created.

I have created the methodize/modulize/pathize methods to allow building 
strings from class names and invertly in a consistant way.


x = ThisIs::MyClass.to_s.methodize #=> this_is__my_class

as you can see, every Upcase letter is prepended by a _ , this allows to 
rebuild the class name without loosing this information. For example 
URI.name.methodize would give "u_r_i".

The first letter is always Upcased according to the ruby convension, so I 
didn't need to prepend it with the underscore character.

You can then get the constant back by using facet/kernel/constant with  
#modulize, which allows to recusively get constants (with the full 

For now, those methods only transform class names to method names or unix 
paths. I could also add the support for method names like :
"MyClass#my_method".methodize #=> ???
"#{klass}#oid".methodize #=> ???


weblog : http://zimba.oree.ch

More information about the Nitro-general mailing list