>>>>> "G" == Gray, Jeff <jeff.gray / intel.com> writes:

G> If you're 'eval'-averse, you could replace the class_eval with a

 yes,

G> method_missing trap instead.

 no :-)

pigeon% cat b.rb
#!/usr/bin/ruby
class Extendable
   def build(name, &block)
      class << self; self; end.send(:define_method, name, &block)
   end
end

a = Extendable.new
a.build(:foo) { |str| puts "foo:#{str}" }
a.build(:noo) { |str1, str2| puts "noo:#{str1};#{str2}" }

a.foo("bar")           #->  "foo:bar"
a.noo("baz", "blah")   #->  "noo:baz;blah"

b = Extendable.new
b.foo("aa")
pigeon% 
pigeon% b.rb
foo:bar
noo:baz;blah
./b.rb:16: undefined method `foo' for #<Extendable:0x401afe4c> (NameError)
pigeon% 



Guy Decoux