extending an object

Discussion in 'Ruby' started by Gerardo Santana Gómez Garrido, Feb 27, 2006.

  1. 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/
     
    Gerardo Santana Gómez Garrido, Feb 27, 2006
    #1
    1. Advertising

  2. Gerardo Santana Gómez Garrido

    Ross Bamford Guest

    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 -
     
    Ross Bamford, Feb 27, 2006
    #2
    1. Advertising

  3. 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 <>:
    > 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 -
    >
    >
    >



    --
    Gerardo Santana
    "Between individuals, as between nations, respect for the rights of
    others is peace" - Don Benito Ju=E1rez
    http://santanatechnotes.blogspot.com/
     
    Gerardo Santana Gómez Garrido, Feb 28, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mark d.
    Replies:
    0
    Views:
    876
    mark d.
    Feb 6, 2006
  2. mike
    Replies:
    2
    Views:
    278
    Larry Bates
    Jan 28, 2005
  3. Rakesh
    Replies:
    10
    Views:
    12,261
    Mike Schilling
    Apr 8, 2008
  4. Bob Hutchison
    Replies:
    5
    Views:
    133
    Bob Hutchison
    Sep 28, 2005
  5. Ittay Dror
    Replies:
    4
    Views:
    109
    Trans
    Oct 22, 2008
Loading...

Share This Page