Rails Plugins: Why to register your own functionality with s

Hi there,

I have seen in the file column plugin (
http://www.kanthak.net/opensource/file_column/) from Sebastian K.
or
David’s acts_as_taggable plugin that to register my functionality I need
to
do something like this:

ApplicationHelper.send(:include, InPlaceEditAssociations)

I am wondering why not:

(a)
module ApplicationHelper
include InPlaceEditAssociatons
end

or:

(b)
ApplicationHelper.include(InPlaceEditAssociations)

As I now know a way that works this is not crucial to me, but I am still
curious.

Cheers,
Mariano

Grmpfh. Sorry, forgot to mention something:
a) results in the methods from my module being available in the
ApplicationHelper directly after my definition but not when accessed
from a
view.
b) results in a error message saying that I tried to call a private
method.

Mariano K. wrote:

Hi there,

I have seen in the file column plugin (
http://www.kanthak.net/opensource/file_column/) from Sebastian K.
or
David’s acts_as_taggable plugin that to register my functionality I need
to
do something like this:

ApplicationHelper.send(:include, InPlaceEditAssociations)

I am wondering why not:

(a)
module ApplicationHelper
include InPlaceEditAssociatons
end

or:

(b)
ApplicationHelper.include(InPlaceEditAssociations)

As I now know a way that works this is not crucial to me, but I am still
curious.

Cheers,
Mariano

With send you can call private methods so,
ApplicationHelper.send(:include, InPlaceEditAssociations) is
ApplicationHelper.include(InPlaceEditAssociations) except it doesn’t
matter that the method is private.

joey__

Hey Joey,

thanks.

I am wondering what is the point of making a method private then? To
give
an indication that this method is not supposed to be called from the
outside?

Cheers,
Mariano

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs