Class: Adrift::FileToAttach::Adapters::Rack

Inherits:
Object
  • Object
show all
Includes:
Adrift::FileToAttach::Adapter
Defined in:
lib/adrift/file_to_attach.rb

Overview

Adapter that allows to attach an uploaded file within a Rack (non-Rails) application.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Adrift::FileToAttach::Adapter

#initialize

Class Method Details

.recognize?(file_representation) ⇒ Boolean

Indicates whether or not file_representation is an uploaded file within a Rack application.

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/adrift/file_to_attach.rb', line 29

def self.recognize?(file_representation)
  file_representation.respond_to?(:has_key?) &&
    file_representation.has_key?(:filename) &&
    file_representation.has_key?(:tempfile)
end

Instance Method Details

#original_filenameObject

Uploaded file’s original filename.



36
37
38
# File 'lib/adrift/file_to_attach.rb', line 36

def original_filename
  @file_representation[:filename]
end

#pathObject

Uploaded file’s path.



41
42
43
# File 'lib/adrift/file_to_attach.rb', line 41

def path
  @file_representation[:tempfile].path
end