to add a constant (class name) to my namespace in an embedded Ruby application. If i want to change the implementation details of that class without restart my application, how can i unrequire and re-require that file?
Strictly speaking, you can't. Well, you can't unrequire. However,
since all classes in Ruby are open, you can simply do the C-side
equivalent of Kernel.load.
-austin
···
On 8/27/05, Iain Dooley <idoo4002@mail.usyd.edu.au> wrote:
rb_require("file.rb");
to add a constant (class name) to my namespace in an embedded Ruby
application. If i want to change the implementation details of that
class without restart my application, how can i unrequire and re-require
that file?
hi Austin, thanks very much for your speedy response
Austin Ziegler wrote:
rb_require("file.rb");
to add a constant (class name) to my namespace in an embedded Ruby
application. If i want to change the implementation details of that
class without restart my application, how can i unrequire and re-require
that file?
Strictly speaking, you can't. Well, you can't unrequire. However,
since all classes in Ruby are open, you can simply do the C-side
equivalent of Kernel.load.
my worry with doing this would be that it would reload the 'Qt' extension that i'm including as well, which takes a while and is done on startup.
i've gotten around the problem by replacing my call to rb_require(filename) with:
that the difference between load and require in a Ruby script is that load will load the file everytime where require will do it only once. is there any reason why rb_load_file does not parse the document into the Ruby namespace? my ruby file looks like this:
class AssignSomeText < Qt::Object
slots 'buttonClicked()'
def setParent(parent) @parent = parent
end
def buttonClicked() @parent.child("textLabel1").text = @parent.child("lineEdit1").text
end
end
if i simply load this file, then AssignSomeText is an undefined constant. if i rb_require() it then AssignSomeText is defined, but if i issue the require command again have changed some implementation details, those changes are not reflected unless i actually restart the application that the ruby interpreter is embedded in
cheers
iain
···
On 8/27/05, Iain Dooley <idoo4002@mail.usyd.edu.au> wrote: