> method_missing does define the method correctly, but it doesn't check > that the method was already defined before it defined attribute > methods. If it did that, it could determine whether the method was > actually missing or whether it was called via super. > > Another way to fix this (besides what Sequel does) would be to perform > the action the attribute method would have performed had it been > defined, without using send to restart the method lookup process. > That would entail copying the logic for the attribute methods into > method_missing (or something called by method_missing).
Ahh, I see... Now I'm wondering, if it's fair enough to say that it is a mistake to overload an attribute this way?: def name; 'hi ' + super.to_s.capitalize; end Technically we don't even overload anything, since the `name` attribute will come into existence only after we bump into method_missing. And at first I thought it is a semantic misuse of the `super` keyword at least since we cannot expect Sequel::Model or AR::Base to know about the attributes we are going to use. Lets say, when I use `super` in that context, I have an intent to delegate the `name` message from the current object into it's parent's class wherever it is Sequel::Model or AR::Base, and the method look up chain reminds me just the regular call of Model#attribute_name, which makes me think that maybe there is no such a big technical mistake to use `super` there... -- Thanks, Ivan -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
