Load wrap=true and adding methods to classes in the prog being called

Discussion in 'Ruby' started by Seb Clediere, Sep 16, 2003.

  1. Seb Clediere

    Seb Clediere Guest

    Dear Rubyists,

    foo.rb:
    class String
    def quote() "'"+self+"'" end
    end

    puts "blabla".quote
    ---

    bar.rb:
    load 'foo.rb', true
    ---

    foo.rb executes ok,
    bar.rb gives "undefined method `quote' for "blabla":String
    (NoMethodError)" which I do understand since the script is now beeing
    executed under an anonymous module.

    Is there a way to still protect the namespace of the caller prog, but
    not having this effect? (i.e. still being able in the called prog to add
    methods to classes defined elsewhere, and whithout these methods
    poluting the caller...)

    Thanks very much!

    Seb.
     
    Seb Clediere, Sep 16, 2003
    #1
    1. Advertising

  2. Seb Clediere

    ts Guest

    >>>>> "S" == Seb Clediere <Sebastien.Clediere@_nospam_laposte.net> writes:

    S> Is there a way to still protect the namespace of the caller prog, but
    S> not having this effect? (i.e. still being able in the called prog to add
    S> methods to classes defined elsewhere, and whithout these methods
    S> poluting the caller...)

    See the module import_module, ruby_behaviors ... in RAA


    Guy Decoux
     
    ts, Sep 16, 2003
    #2
    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. -intl.com
    Replies:
    1
    Views:
    381
    Martin Gregorie
    Oct 22, 2006
  2. Aaron Fude

    To wrap or not to wrap?

    Aaron Fude, May 8, 2008, in forum: Java
    Replies:
    12
    Views:
    738
    Chronic Philharmonic
    May 10, 2008
  3. bdb112
    Replies:
    45
    Views:
    1,422
    jazbees
    Apr 29, 2009
  4. Felix
    Replies:
    1
    Views:
    363
    Felix
    Sep 29, 2006
  5. Art Werschulz

    Text::Wrap::wrap difference

    Art Werschulz, Sep 22, 2003, in forum: Perl Misc
    Replies:
    0
    Views:
    270
    Art Werschulz
    Sep 22, 2003
Loading...

Share This Page