Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > extending an object

Reply
Thread Tools

extending an object

 
 
Gerardo Santana Gómez Garrido
Guest
Posts: n/a
 
      02-27-2006
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=E1rez
http://santanatechnotes.blogspot.com/


 
Reply With Quote
 
 
 
 
Ross Bamford
Guest
Posts: n/a
 
      02-27-2006
On Mon, 2006-02-27 at 16:16 +0900, Gerardo Santana G=C3=B3mez 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:
>=20
> rb_extend_object(self, rb_mAModuleExtension);
>=20
> 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.

--=20
Ross Bamford - http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
 
Gerardo Santana Gómez Garrido
Guest
Posts: n/a
 
      02-28-2006
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 <(E-Mail Removed)>:
> On Mon, 2006-02-27 at 16:16 +0900, Gerardo Santana G=F3mez 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.
>
> --
> Ross Bamford - (E-Mail Removed)
>
>
>



--
Gerardo Santana
"Between individuals, as between nations, respect for the rights of
others is peace" - Don Benito Ju=E1rez
http://santanatechnotes.blogspot.com/


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
extending object with another object Ittay Dror Ruby 4 10-22-2008 07:17 PM
java.util.Properties extending from HashMap<Object, Object> insteadof HashMap<String, String> Rakesh Java 10 04-08-2008 04:22 AM
Examples on Extending MembershipUser Object mark d. ASP .Net 0 02-06-2006 03:44 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
is extending an object considered acceptable usage? mike Python 2 01-28-2005 02:49 PM



Advertisments