From: Shak Shak Date: 2009-07-01T06:28:08+09:00 Subject: Dynamically creating class methods I want to create a class method which allows us to create further class methods, so something like: class Test class << self def create_method(name, proc) self.class.send(:define_method, name, proc) end end end proc = lambda {puts 'Hello world'} Test.create_method(:foo, proc) Test.foo #want this Integer.foo #don't want this The problem with the above is that create_method adds foo to all classes. self.send on its own doesn't seem to do what I want - it adds foo as instance method instead. The method will eventually be placed in an module to be mixed in when desired, although I don't think that matters here. Ideas? -- Posted via http://www.ruby-forum.com/.