require "active_job" module InstDataShipper module Jobs class Base < ActiveJob::Base attr_reader :start_time before_perform do @start_time = DateTime.now end around_perform :cleanup_working_dir def working_dir @working_dir ||= Dir.mktmpdir end private def cleanup_working_dir yield if block_given? ensure FileUtils.remove_entry @working_dir if @working_dir end end end end