How do I use define_method to create class methods?

Posted by Chinasaur on Stack Overflow See other posts from Stack Overflow or by Chinasaur
Published on 2009-04-15T17:03:04Z Indexed on 2010/04/16 20:33 UTC
Read the original article Hit count: 144

This is useful if you are trying to create class methods metaprogramatically:

def self.create_methods(method_name)
    # To create instance methods:
    define_method method_name do
      ...
    end

    # To create class methods that refer to the args on create_methods:
    ???
end

My answer to follow...

© Stack Overflow or respective owner

Related posts about ruby

Related posts about metaprogramming