Forum: Ruby on Rails Why .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.
danfrost (Guest)
on 2009-04-20 00:27
(Received via mailing list)
Hi all,

Could anyone tell me why you use .send when callling "include" in
rails plugins??

E.g.
  ActiveRecord::Base.send :include, SomeClass::ClassMethods

Cheers,
Dan
Phlip (Guest)
on 2009-04-20 00:30
(Received via mailing list)
danfrost wrote:

> Could anyone tell me why you use .send when callling "include" in
> rails plugins??
>
> E.g.
>   ActiveRecord::Base.send :include, SomeClass::ClassMethods

Take it out and see.

.include is protected or private or something. send() just says "shut up
and do
exactly what I say, b----!"

--
   Phlip
   http://flea.sourceforge.net/resume.html
danfrost (Guest)
on 2009-04-20 02:32
(Received via mailing list)
Thanks - nice answer.

So, ".send" by-passes all private / protected restrictions?
Shaun K. (Guest)
on 2009-04-22 12:33
danfrost wrote:
> Thanks - nice answer.
>
> So, ".send" by-passes all private / protected restrictions?

In 1.8, definitely. In 1.9...I think I read somewhere that it didn't any
more. Don't quote me on that, though. If it's used in the rails plugins,
that wouldn't really make sense.
Frederick C. (Guest)
on 2009-04-22 14:40
(Received via mailing list)
On Apr 22, 9:33 am, Shaun K. <removed_email_address@domain.invalid>
wrote:
> danfrost wrote:
> > Thanks - nice answer.
>
> > So, ".send" by-passes all private / protected restrictions?
>
> In 1.8, definitely. In 1.9...I think I read somewhere that it didn't any
> more. Don't quote me on that, though. If it's used in the rails plugins,
> that wouldn't really make sense.

1.9 was like that for a while (with a separate send! that still
ignored whether a method was private/protected) but that was
eventually removed.

Fred
This topic is locked and can not be replied to.