Skip to content

Instantly share code, notes, and snippets.

@certainty
Created February 21, 2014 17:58
Show Gist options
  • Save certainty/9139535 to your computer and use it in GitHub Desktop.
Save certainty/9139535 to your computer and use it in GitHub Desktop.
class Foo
def self.set_finalizer(obj)
ObjectSpace.define_finalizer(obj,method(:finalize))
end
def self.set_finalizer2(obj)
ObjectSpace.define_finalizer(obj,finalize2)
end
def self.finalize
puts "finalizer"
end
def self.finalize2
proc{ puts "finalizer 2" }
end
end
Foo.set_finalizer(Foo.new)
Foo.set_finalizer2(Foo.new)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment