Loading a file into a new namespace: solutions and explanations?

Hi guys,

Consider this here:

def foo
puts ‘hi from foo()’
end

In file called foo.rb

Now this is not in a special module, thus I assume it is part
of class Object.

Is there a way to attach this method into a new namespace
dynamically, without modifying that file?

load() allows only an anonymouse module, but I want to give
this method a namespace at runtime. I want to extend it
and I am surprised that ruby has no simple way to allow
that.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs