From: Erik Veenstra Date: 2006-08-07T18:38:25+09:00 Subject: Re: method_missing to define_method > class Person > @attributes = {} This is not going to work... Well, it is going to work, but it doesn't do what you expected (I suppose)... You're referring to the instance variable of the class, which isn't the same has the instance variable of an instance of the class. > def initialize attributes > @attributes.merge! attributes > end Because of the previous error, you're calling merge! of nil... Why not "@attributes = attributes", as usual? You usually initialize an object only once, anyway. > def method_missing name > if @attributes.has_key? name > class_eval do Object#.class_eval ??? > define_method(name) do |name| define_method(name) do > @attributes[name] > end > end self.send(name) > else > # other magic > end > end > end > > And, consider that this example is very simple, ... but it doesn't work... ;] gegroet, Erik V. - http://www.erikveen.dds.nl/