On May 23, 2005, at 4:24 PM, Markus wrote: > On Mon, 2005-05-23 at 13:46, Jamis Buck wrote: > >>> >>> >>>>> Adding: >>>>> >>>>> class Array >>>>> def self.===(other) >>>>> other.is_a? self >>>>> end >>>>> end >>>>> >>>>> right above the code in question fixes it. >>>>> >>>>> > > >> It's proxying to an array, and undefining all the relevant methods on >> the proxy so that things like #class get passed to the proxy, too. >> Unfortunately, it looks like === doesn't get proxied, and I'm not >> sure why. Perhaps Ruby does some optimizing under the covers? >> > > So my conclusion: > > This is a bug in the code that does the proxying, and either the > following snippet should be added to the proxy class: > > class AssociationProxy > def self.===(other) > other.is_a? Array > end > end Except that you'd want to add that to Array, rather than the proxy class, because (as Jacob said), it is used like Array.===(instance) instead of the other way around. > > or "class" should be removed from set of the proxied methods. That's probably a good idea, but I still don't know if it would help. Also as Jacob said, === is implemented in C and probably bypasses the Ruby code, checking the class directly. > > Otherwise, it breaks the semantics of a number of Ruby idioms for no > good reason--in other words, it's a bug, not a feature. > > Any idea who owns this or who I should propagate it to? Jamis? You can add a ticket to dev.rubyonrails.com. That way it won't get lost in a shuffle of email. - Jamis