Re: Spira: method resolution of has_many resources not working sometimes

On Fri, May 20, 2011 at 12:11:10PM -0500, Ben Lavender wrote:
> This is a quirk of Promise. In Ruby 1.8, there is no BasicObject, so
> Promise fakes it by undefining all of the non-critical methods on
> Object. When you monkey-patch Object to have a to_zorch, Promise does
> not pass the method through to the underlying promised thunk, and you
> get Object's version. In Ruby 1.9 (which I tested, which is why I did
> not see the same behavior), Promise uses BasicObject, which did not
> get #to_zorch added to it by adding it to Object. I do not imagine
> this behavior would happen in any case other than monkey-patching
> Object itself.

OK. Thanks for the explanation.  I was already wondering if this was
different in 1.9.

I discovered this because Rails monkey-patches Object with e.g. to_param
which is kinda important. 

I guess another workaround is to removed the methods that Rails monkey-patches
into Object from Promise.

It would be nice if that behaviour of promise were documented.

--chris

Received on Friday, 20 May 2011 20:13:14 UTC