[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Redefine "method" method

Iñaki Baz Castillo

8/13/2008 8:10:00 PM

Hi, I'd like to have a method called "method" in some classes, but=20
since "method" is a Ruby method present in any class I would like if it cou=
ld=20
originate any problem.

=2D-=20
I=C3=B1aki Baz Castillo

6 Answers

Tommy Morgan

8/13/2008 8:31:00 PM

0

Technically, it seems that you could do something along the lines of the
following:

class Test
class << self
undef_method "method"
end
end

Although... that really seems like a bad idea. I don't know enough about th=
e
internals to say whether or not anything would break (I poked at it a littl=
e
and haven't tripped across any side effects, but it seems like there should
be).

Any chance you could just use a different name for your method?

--Tommy M.

On Wed, Aug 13, 2008 at 4:10 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
:

> Hi, I'd like to have a method called "method" in some classes, but
> since "method" is a Ruby method present in any class I would like if it
> could
> originate any problem.
>
> --
> I=F1aki Baz Castillo
>
>

Iñaki Baz Castillo

8/13/2008 8:47:00 PM

0

El Mi=C3=A9rcoles, 13 de Agosto de 2008, Tommy Morgan escribi=C3=B3:
> Any chance you could just use a different name for your method?

Of course, but I'm doing a SIP protocol application, in which a core concep=
t=20
is the *method* (INVITE, ACK, BYE...), so it would be really nice to use:

request.method

instead of:

request.sip_method <--- This is what I use for now.

Thanks.

=2D-=20
I=C3=B1aki Baz Castillo

Robert Klemme

8/13/2008 8:54:00 PM

0

On 13.08.2008 22:10, Iñaki Baz Castillo wrote:
> Hi, I'd like to have a method called "method" in some classes, but
> since "method" is a Ruby method present in any class I would like if it could
> originate any problem.

I'd say the idea is not so good because - depending on libraries that
you use - you might experience errors or strange behavior. I'd rather
choose a different name if at all possible.

Kind regards

robert

Iñaki Baz Castillo

8/13/2008 8:59:00 PM

0

El Mi=E9rcoles, 13 de Agosto de 2008, Robert Klemme escribi=F3:
> On 13.08.2008 22:10, I=F1aki Baz Castillo wrote:
> > Hi, I'd like to have a method called "method" in some classes, but
> > since "method" is a Ruby method present in any class I would like if it
> > could originate any problem.
>
> I'd say the idea is not so good because - depending on libraries that
> you use - you might experience errors or strange behavior. I'd rather
> choose a different name if at all possible.

Thanks.
In fact, I've just realized that I can use "Method" nada :)


=2D-=20
I=F1aki Baz Castillo

Tommy Morgan

8/13/2008 9:04:00 PM

0

Well, for what it's wirth:

I think request.sip_method is actually better.
While it's important to try and go for naming conventions in your code that
are succinct, you also want to avoid ambiguity. If someone else is looking
at your code and they see 'request.method', it isn't obvious that you are
referring to something aside from what is built into ruby. sip_method helps
to avoid that ambiguity, and it also allows you to go back and utilize the
built-in method if you need to at some point in the future.

Hope that helps.

--Tommy M.

On Wed, Aug 13, 2008 at 4:46 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=
:

> El Mi=E9rcoles, 13 de Agosto de 2008, Tommy Morgan escribi=F3:
> > Any chance you could just use a different name for your method?
>
> Of course, but I'm doing a SIP protocol application, in which a core
> concept
> is the *method* (INVITE, ACK, BYE...), so it would be really nice to use:
>
> request.method
>
> instead of:
>
> request.sip_method <--- This is what I use for now.
>
> Thanks.
>
> --
> I=F1aki Baz Castillo
>
>

Iñaki Baz Castillo

8/13/2008 9:39:00 PM

0

El Mi=C3=A9rcoles, 13 de Agosto de 2008, Tommy Morgan escribi=C3=B3:
> Well, for what it's wirth:
>
> I think request.sip_method is actually better.
> While it's important to try and go for naming conventions in your code th=
at
> are succinct, you also want to avoid ambiguity. If someone else is looking
> at your code and they see 'request.method', it isn't obvious that you are
> referring to something aside from what is built into ruby. sip_method hel=
ps
> to avoid that ambiguity, and it also allows you to go back and utilize the
> built-in method if you need to at some point in the future.
>
> Hope that helps.

Enough arguments to remain using "sip_method" :)

Thanks.

=2D-=20
I=C3=B1aki Baz Castillo