Why .send?


#1

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


#2

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


#3

Thanks - nice answer.

So, “.send” by-passes all private / protected restrictions?


#4

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.


#5

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