Forum: Ruby on Rails Locating the source of ActiveRecord::Base.send

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric (Guest)
on 2007-02-27 01:04
(Received via mailing list)
I downloaded a plugin and was looking over the code when I came across
ActiveRecord::Base.send. I noticed that several tutorials stated that
you just call the method to mixin your new plugin class. Curious as to
what the actual defintion of the "send" method was, I looked at the
api and found no mention of it.

How does one usually go about searching for the source of the method?
It's not the first method I've come across where it wasn't listed in
the docs so ideally I would like to know what steps you go through to
find the definition of something so the next time I can figure it out
by myself.

Thanks,

Eric
Bala P. (Guest)
on 2007-02-27 01:10
(Received via mailing list)
send is actually a method that is used to call private methods
declared in a class. Ruby for Rails book has some good tips on how to
go about figuring out whether Base is a class or module and how to
track down the methods.
Matthew M. (Guest)
on 2007-02-27 01:28
(Received via mailing list)
Eric wrote:
> by myself.
>
> Thanks,
>
> Eric
>
>
> >
>
It is a ruby thing.  Check out
http://www.ruby-doc.org/core/classes/Object.html#M000292

Matt M.
blog.mattmargolis.net
javier ramirez (Guest)
on 2007-02-27 01:41
(Received via mailing list)
> I downloaded a plugin and was looking over the code when I came across
> ActiveRecord::Base.send. I noticed that several tutorials stated that
> you just call the method to mixin your new plugin class. Curious as to
> what the actual defintion of the "send" method was, I looked at the
> api and found no mention of it.
>
don't forget Rails is "just" a framework on top of Rails, but the
programming language itself is Ruby. In this case, "send" is one of the
methods Object (in Ruby). It's one of the ways available for dynamically
call a method on any object.

> How does one usually go about searching for the source of the method?
>
If you cannot find the method in the source of your class, then take a
look at its mixins and parent classes.

If still not there, then it's very likely that it is a method either of
Object, Class or Module, in Ruby. Unfortunately, the source of these
methods is in C, in case you want to take a look at their source. The
good news is that the C code is pretty well structured and commented, so
many times it's readable enough.

regards,

javier ramirez

--
--------
Estamos de estreno... si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!
This topic is locked and can not be replied to.