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.
B00c6be2202b8995827c12636ae23db6?d=identicon&s=25 danfrost (Guest)
on 2009-04-19 22: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
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-19 22: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
B00c6be2202b8995827c12636ae23db6?d=identicon&s=25 danfrost (Guest)
on 2009-04-20 00:32
(Received via mailing list)
Thanks - nice answer.

So, ".send" by-passes all private / protected restrictions?
82b09b041448e75d040587fa76f240c1?d=identicon&s=25 Shaun Keller (akira)
on 2009-04-22 10: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.
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-22 12:40
(Received via mailing list)
On Apr 22, 9:33 am, Shaun Keller <rails-mailing-l...@andreas-s.net>
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.