On Sun, Jul 1, 2012 at 3:15 PM, Cees Zeelenberg <[email protected]> wrote: > Many thanks for all the contributions.
You're welcome! > Let me first try to explain a little bit further why I wanted tho change > the 'new' class method. > I have recently implemented a set of JRuby bindings for the QtJambi > Library. QtJambi is the Java version of the Qt GUI framework, a > cross-platform application development toolkit. > The library consists of several hundred Java classes and Interfaces. In > JRuby these can all be accessed through the Qt:: namespace. > Classes and Modules are 'lazily' loaded when they are accessed through > the 'const_missing' method. > In this method a constant is assigned to the underlying Java Class and a > class method 'new' is defined similar to the one mentioned in one of the > postings: I haven't looked at the code, but did you consider a different solution, like not assigning the Java class to the constant but something else? For example, you can create an Object instance, define method new for it (which will create the Java class instance and do custom initialization) and probably a few others as well (e.g. superclass, ancestors, :=== etc...). That way you could create a wrapping layer without the need to fiddle with Java classes. You might have to add instance methods to get back to your wrapper "classes" from instances. > Thanks to the posting of Robert Klemme I understand better what happens > when changing a 'new' class method, but I can't say I fully understand > it, so it seems safer not to interfere. If you have further questions just let us know. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/ -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
