class PDFService::Utils::TempfileService

Public Class Methods

new(root: Pathname('.')) click to toggle source
# File lib/pdf_service/utils/tempfile_service.rb, line 4
def initialize(root: Pathname('.'))
  @root = Pathname(root)
end

Public Instance Methods

use(name: SecureRandom.hex, extension: 'tmp') { |path| ... } click to toggle source
# File lib/pdf_service/utils/tempfile_service.rb, line 8
def use(name: SecureRandom.hex, extension: 'tmp')
  path = Pathname('.').expand_path.join("#{name}.#{extension}")
  yield(path)
ensure
  path.unlink if path.exist?
end