List Info

Thread: Re: method_missing for Enumerator




Re: method_missing for Enumerator
user name
2007-06-25 15:24:27
On 6/25/07, TRANS <transfiregmail.com> wrote:
> On 6/25/07, Rick DeNatale <rick.denatalegmail.com> wrote:

> > I had the same reaction.  There are issues with
how you compose uses
> > of method_missing.
> >
> > Note that rspec had to do away with using
method_missing because it
> > and activerecord were 'fighting' over it.
> >
> > http://blog.davidchelimsk
y.net/articles/2007/01/10/rspec-should-use_a_little_less_mag
ic
>
> It doesn't explain how the conflict was arising. It's
usually pretty
> easy to avoid conflicts --as long as the set of methods
don't overlap.
> You simply alias the original method_missing and use it
as a fallback.

The problem is when you can't in general tell if the methods
overlap.
For example, your method_missing doesn't handle a particular
set of
methods, iit just blindly forwards to the elements.

A lot of uses of method_missing are dynamic, and don't have
a fixed
set of messages they handle. The point is that it's quite
hard if not
impossible to come up with a set of 'standards' for
composing
method_missing which don't provide opportunities for
unpleasant
surprises.


> RSpec's old syntax was fundamentally flawed (a bad idea
they got from
> Rails!) and unfortunately the new syntax isn't much
better either.
> Anyway, I digress.

Not sure if it's the syntax or the implementation.  As far
as I can
see doing away with the use of method_missing didn't require
a syntax
change.  The big problem I sense with RSpec it how many
methods they
add to both Object and Kernel.  I'm not sure how good it is
for a test
tool to alter the subjects of the test so much.

-- 
Rick DeNatale

My blog on Ruby
http://talklikead
uck.denhaven2.com/


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )