Module: Shrine::Plugins::Tempfile::ClassMethods

Defined in:
lib/shrine/plugins/tempfile.rb

Instance Method Summary collapse

Instance Method Details

#with_file(io) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/shrine/plugins/tempfile.rb', line 8

def with_file(io)
  if io.is_a?(UploadedFile) && io.opened?
    # open a new file descriptor for thread safety
    File.open(io.tempfile.path, binmode: true) do |file|
      yield file
    end
  else
    super
  end
end