Skip to content

Instantly share code, notes, and snippets.

@nerdEd
Created Jan 19, 2012
Embed
What would you like to do?
Using ObjectSpace.define_finalizer
class Source
def initialize(source_zip)
@tmp_dir = Dir.mktmpdir
ObjectSpace.define_finalizer(self, self.class.finalize(@tmp_dir))
# Dump contents of zip into tmp dir
end
def self.finalize(tmp_dir)
proc {FileUtils.rm_rf(tmp_dir)}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment