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
on 2007-02-27 01:04
on 2007-02-27 01:10
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.
on 2007-02-27 01:28
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
on 2007-02-27 01:41
> 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!!