Forum: Ruby on Rails Rails Plugins: Why to register your own functionality with s

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.
838869251cf09420cc80a9e008adddc1?d=identicon&s=25 Mariano Kamp (Guest)
on 2006-03-25 16:52
(Received via mailing list)
Hi there,

I have seen in the file column plugin (
http://www.kanthak.net/opensource/file_column/) from Sebastian Kanthak
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
838869251cf09420cc80a9e008adddc1?d=identicon&s=25 Mariano Kamp (Guest)
on 2006-03-25 17:15
(Received via mailing list)
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.
6dab365a82517fb694650a57ee88e4a4?d=identicon&s=25 joey__ (Guest)
on 2006-03-26 10:10
Mariano Kamp wrote:
> Hi there,
>
> I have seen in the file column plugin (
> http://www.kanthak.net/opensource/file_column/) from Sebastian Kanthak
> 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__
838869251cf09420cc80a9e008adddc1?d=identicon&s=25 Mariano Kamp (Guest)
on 2006-03-30 07:01
(Received via mailing list)
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 topic is locked and can not be replied to.