Destroy object from memory.. Object.const_destroy?

Hey all,

If I'm instantiating a instance of a class at using Object.const_get.
How can I destroy it so that next time it reloads and code changes will
take effect?

Thanks.

···

--
Posted via http://www.ruby-forum.com/.

Hi,

If I'm instantiating a instance of a class at using Object.const_get.
How can I destroy it so that next time it reloads and code changes will
take effect?

I am not sure what you mean here. You don't instantiate anything
using const_get. You just get the reference to the existing object.
If you want to redefine class objects (without warning), you remove
the constant using remove_const(), and reload the program using
load(). But I'd recommend restarting the program, unless reloading is
absolutely necessary.

              matz.

···

In message "Re: Destroy object from memory.. Object.const_destroy?" on Thu, 5 Jul 2007 03:56:01 +0900, Aaron Smith <beingthexemplary@gmail.com> writes:

Yukihiro Matsumoto wrote:

Hi,

>If I'm instantiating a instance of a class at using Object.const_get.
>How can I destroy it so that next time it reloads and code changes will
>take effect?

I am not sure what you mean here. You don't instantiate anything
using const_get. You just get the reference to the existing object.
If you want to redefine class objects (without warning), you remove
the constant using remove_const(), and reload the program using
load(). But I'd recommend restarting the program, unless reloading is
absolutely necessary.

              matz.

Thanks,

That's pretty much what I was looking for. The problem I'm having is
with a plugin in Rails. Once it runs, if code is executed, then changed
at all, I have to restart Rails. Default rails controllers update just
fine. They're probably using the remove_const(). But with my plugin I
want to have the same functionality...

Are there any major risks doing this? Wouldn't seem like it.
Thanks

···

In message "Re: Destroy object from memory.. Object.const_destroy?" > on Thu, 5 Jul 2007 03:56:01 +0900, Aaron Smith > <beingthexemplary@gmail.com> writes:

--
Posted via http://www.ruby-forum.com/\.

Are you talking about the way Rails reloads classes in development mode? You can enable this in your own classes using:

   class MyClass
     include Reloadable
   end

James Edward Gray II

···

On Jul 5, 2007, at 9:40 AM, Aaron Smith wrote:

Yukihiro Matsumoto wrote:

Hi,

In message "Re: Destroy object from memory.. Object.const_destroy?" >> on Thu, 5 Jul 2007 03:56:01 +0900, Aaron Smith >> <beingthexemplary@gmail.com> writes:

>If I'm instantiating a instance of a class at using Object.const_get.
>How can I destroy it so that next time it reloads and code changes will
>take effect?

I am not sure what you mean here. You don't instantiate anything
using const_get. You just get the reference to the existing object.
If you want to redefine class objects (without warning), you remove
the constant using remove_const(), and reload the program using
load(). But I'd recommend restarting the program, unless reloading is
absolutely necessary.

              matz.

Thanks,

That's pretty much what I was looking for. The problem I'm having is
with a plugin in Rails. Once it runs, if code is executed, then changed
at all, I have to restart Rails. Default rails controllers update just
fine. They're probably using the remove_const(). But with my plugin I
want to have the same functionality...

That's pretty much what I was looking for. The problem I'm having is
with a plugin in Rails. Once it runs, if code is executed, then
changed
at all, I have to restart Rails. Default rails controllers update just
fine. They're probably using the remove_const(). But with my plugin I
want to have the same functionality...

Are you talking about the way Rails reloads classes in development
mode? You can enable this in your own classes using:

   class MyClass
     include Reloadable
   end

James Edward Gray II

That's another good solution. Thanks.

···

--
Posted via http://www.ruby-forum.com/\.