From: Robert Klemme Date: 2011-12-08T19:53:21+09:00 Subject: Re: Using any trick to omit () in constant lookup? On Thu, Dec 8, 2011 at 10:35 AM, Hans Mackowiak wrote: > or an idea, forgot your Button class, and override const_missing There is a much simpler solution require 'gtk2' $use_gtk = true def Button if $use_gtk Gtk::Button else # else use something else. raise "unknown" end.new end x = Button puts x.class But the problem will come later, i.e. when using all those toolkit instances. They most likely have different interfaces. So you better wrap all the classes with your own classes which exhibit a standard interface (which you must define) and work with specific toolkit classes behind the scenes. The ugly thing then will be to find the way back from a toolkit class to its corresponding wrapper. Another option could be to add methods to toolkit classes to create the uniform interface. I am not sure whether all the effort pays off though... Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/