From: Judson Lester Date: 2007-12-15T15:07:29+09:00 Subject: Pros and cons on dynamic method generation ------=_Part_4544_13700666.1197698838810 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline So, I know two ways to do something like the following: class Contrived @@examples = {} def self.create_example_accessor(name) class_eval <<-EOM def #{name}() return @@examples[#{name}] end EOM end def self.relink_example_accessor(name) alias_method(:name, :_example_accessor) end def _example_accessor me = /:in `([^']*)/.match(caller(0).first) return @@examples[me] end end I sort of like relink_example_accessor for giving better backtraces and just generally not being evaluating a string. I'd like to have something cleaner than either, just in general, and I'd like to also have a better understanding of the pros and cons on each. Judson -- Your subnet is currently 169.254.0.0/16. You are likely to be eaten by a grue. ------=_Part_4544_13700666.1197698838810--