Judson Lester
12/15/2007 6:07:00 AM
[Note: parts of this message were removed to make it a legal post.]
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.