Is there any way to tune the translator that turns Java-formatted method names into Ruby-formatted method names? I'm using JAXB-generated classes for an XML schema to create Ruby bindings and am encountering cases where the translation is very unintuitive. For example, "getIndicatedTTPs" is getting turned into "get_indicated_tt_ps" when I would prefer something like "get_indicated_ttps". Obviously I can solve this as a one-off by aliasing the method but "TTP" is a common term throughout the schema (and therefore the generated content) so I'd rather just tell it to turn "TTPs" into "ttps" as a global case. I briefly looked through the JRuby code and Googled but wasn't able to find any easy way to hook into it to do this. Thanks!
on 2013-10-08 15:26
on 2013-10-09 20:40
but you can also call it with the original method name, right ? I'm missing something , what translator do you mean ? I figured jruby did the match at invocation time , does Jruby actually insert new method keys in the method dictionary on the Java proxy class to accommodate for the snake style method naming convention ? Just curious Charles
on 2013-10-09 21:00
Yes, you can still call it with the original method name (as well as the poorly translated name). So it's not "broken" per se, but I'm developing a library for others to use and would like to give them a clean and consistent Ruby-style interface. I can't profess to know much about the internals of JRuby but if you inspect an instance of a Java proxy class it has both the original Java-style methods and the translated Ruby-style methods defined.
on 2013-10-10 05:43
Charles - I posted a pry session at https://gist.github.com/keithrbennett/6912655 that shows a Java class (java.util.Locale). Note the default=, which is a Rubified version of setDefault. It's interesting that setDefault is not listed there, although it works, as shown in the pry session. Anyway, to answer your question, it's not done at invocation time. - Keith
on 2013-10-10 07:50
"It's interesting that setDefault is not listed there, although it works, as shown in the pry session" Well, this seems to be a side effect of pry only (like pry applying some smart filter in case of java setters/getters?)... If you try this (in a similar session pry session, but _not_ using pry 'ls'), you'll see it should be listed:  pry(Java::JavaUtil::Locale):1> methods.grep /default/i => ["set_default", "default", "setDefault", "init_default", "default=", "getDefault", "initDefault", "get_default"]
on 2013-10-10 17:51
thanks So I guess when one utilizes an external jar , Jruby must at least lazily cache the selectors. Charles