S
Seb Clediere
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.
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.