Redefine "method" method

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ñaki Baz Castillo

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 the
internals to say whether or not anything would break (I poked at it a little
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ñaki 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ñaki Baz Castillo

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

···

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.

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.

···

El Miércoles, 13 de Agosto de 2008, Tommy Morgan escribió:

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

--
Iñaki Baz Castillo

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

···

El Miércoles, 13 de Agosto de 2008, Robert Klemme escribió:

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.

--
Iñaki Baz Castillo

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ñaki Baz Castillo <ibc@aliax.net> wrote:

El Miércoles, 13 de Agosto de 2008, Tommy Morgan escribió:
> 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ñaki Baz Castillo

Enough arguments to remain using "sip_method" :slight_smile:

Thanks.

···

El Miércoles, 13 de Agosto de 2008, Tommy Morgan escribió:

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.

--
Iñaki Baz Castillo