Forum: Ruby extending an object

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.
5a601582df3b42b65a5e8353fc9305da?d=identicon&s=25 Gerardo Santana Gómez Garrido (Guest)
on 2006-02-27 08:18
(Received via mailing list)
I'm writing an extension for Ruby, and want to extend an object with
methods from a module. I'm doing it like this:

rb_extend_object(self, rb_mAModuleExtension);

But the methods added to self become private. I want them public. How
should this be done?

Thanks in advance.

--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Juárez
http://santanatechnotes.blogspot.com/
A9b6a93b860020caf9d2d1d58c32478f?d=identicon&s=25 Ross Bamford (Guest)
on 2006-02-27 10:47
(Received via mailing list)
On Mon, 2006-02-27 at 16:16 +0900, Gerardo Santana Gómez Garrido wrote:
> I'm writing an extension for Ruby, and want to extend an object with
> methods from a module. I'm doing it like this:
>
> rb_extend_object(self, rb_mAModuleExtension);
>
> But the methods added to self become private. I want them public. How
> should this be done?

I think rb_extend_object retains the original access of module instance
methods, so you should need to just define them public in the module
you're extending.
5a601582df3b42b65a5e8353fc9305da?d=identicon&s=25 Gerardo Santana Gómez Garrido (Guest)
on 2006-02-28 03:51
(Received via mailing list)
Thanks Ross, it's solved. For the record, I was using
rb_define_module_function insted of rb_define_method for defining a
method in the module.

2006/2/27, Ross Bamford <rossrt@roscopeco.co.uk>:
> methods, so you should need to just define them public in the module
> you're extending.
>
> --
> Ross Bamford - rosco@roscopeco.REMOVE.co.uk
>
>
>


--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Juárez
http://santanatechnotes.blogspot.com/
This topic is locked and can not be replied to.