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.
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.
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.
On 13.08.2008 22:10, Iñaki Baz C. 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
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.
El Miércoles, 13 de Agosto de 2008, Robert K.
escribió:> On 13.08.2008 22:10, Iñaki Baz C. 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
El Miércoles, 13 de Agosto de 2008, Tommy Morgan escribió:
Hope that helps.
Enough arguments to remain using “sip_method”
Thanks.