Forum: Ruby on Rails Object Finalizers help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ffecaee0d49f054bf7653c5f89228c7f?d=identicon&s=25 Adam Ballai (Guest)
on 2006-02-20 17:22
(Received via mailing list)
Heya guys,

   This one is bothering me as its evading my eye.  I'm trying to set a
callback on finalization of an object, ie: a finalizer set through a
plugin to the model.

Example In Plugin:
def acts_as_goat
  class_eval do
    ObjectSpace.define_finalizer(self, Proc.new {self.conn.close} )
  end
end

class UberGoat < ActiveRecord::Base
  acts_as_goat
end

Anyways, it seems to not be calling the finalizer?  Is this the correct
way to set a finalizer or am I going about it the wrong way.   I need to
close a socket connection _after_ the model is done being used, not
necessarily a destroy, but out of scope where GC usually happens.

Thanks for any help.
This topic is locked and can not be replied to.