Class: Adrift::FileToAttach::Adapters::Rack
- Inherits:
-
Object
- Object
- Adrift::FileToAttach::Adapters::Rack
- 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
-
.recognize?(file_representation) ⇒ Boolean
Indicates whether or not
file_representation
is an uploaded file within a Rack application.
Instance Method Summary collapse
-
#original_filename ⇒ Object
Uploaded file’s original filename.
-
#path ⇒ Object
Uploaded file’s path.
Methods included from Adrift::FileToAttach::Adapter
Class Method Details
.recognize?(file_representation) ⇒ Boolean
Indicates whether or not file_representation
is an uploaded file within a Rack application.
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_filename ⇒ Object
Uploaded file’s original filename.
36 37 38 |
# File 'lib/adrift/file_to_attach.rb', line 36 def original_filename @file_representation[:filename] end |
#path ⇒ Object
Uploaded file’s path.
41 42 43 |
# File 'lib/adrift/file_to_attach.rb', line 41 def path @file_representation[:tempfile].path end |