On May 30, 2007, at 8:34 AM, Robert Dober wrote:

> On 5/30/07, James Edward Gray II <james / grayproductions.net> wrote:
>> On May 30, 2007, at 7:53 AM, dblack / wobblini.net wrote:
>>
>> > You could of course shoehorn find_by_* into respond_to? for AR
>> > objects, if you don't mind, essentially, writing method_missing  
>> twice
>> > (once for real, once as a kind of pseudo-static twin).
>>
>> I don't really understand this stance.  My opinion is that providing
>> a method_missing() implementation is a convenient way for a
>> programmer to define a lot of dynamic methods.  This increases the
>> messages an object responds to.
>
> I have always felt that dynamic method creation and dynamic message
> interception are not quite the same beast. But I guess you have some
> thoughts behind your claim of which I fail to grasp the concept. Would
> you mind to elaborate?

I'm not really sure what else to say.  I read the documentation for  
respond_to?():

$ ri -T Object#respond_to?
----------------------------------------------------- Object#respond_to?
      obj.respond_to?(symbol, include_private=false) => true or false
------------------------------------------------------------------------
      Returns +true+> if _obj_ responds to the given method. Private
      methods are included in the search only if the optional second
      parameter evaluates to +true+.

I know that ActiveRecord model classes will except find_by_*()  
methods, so the fact that respond_to?() returns false for them makes  
the above documentation lie.  That does not seem good to me and it's  
certainly possible to fix it.  Thus, I can only reason that it is a  
bug in ActiveRecord.

> Is this really a good idea?

Is it a good idea not to?  What exactly is the use case for  
respond_to?()?  I have only ever used it to find out if something I  
want is available.  If I can't do that reliably, it doesn't really  
help me much.

James Edward Gray II