From: Joel Pearson Date: 2013-01-30T18:28:45+09:00 Subject: Re: question on watir I've never tried this before, but after a little digging I got this to work: irb(main):001:0> class Raja irb(main):002:1> def initialize irb(main):003:2> create_method(:raja) {puts 'raja'} irb(main):004:2> end irb(main):005:1> def create_method(name, &block) irb(main):006:2> self.class.send(:define_method, name, &block) irb(main):007:2> end irb(main):008:1> end => nil irb(main):009:0> Raja.new.raja raja I used the "create_method" example from the Module documentation, and then used initialize to trigger it when the class is created via "new". Of course you could iterate through a hash or array to populate your class with multiple methods. -- Posted via http://www.ruby-forum.com/.