Class: Rack::Test::UploadedFile
- Inherits:
-
Object
- Object
- Rack::Test::UploadedFile
- Defined in:
- lib/rack/test/uploaded_file.rb
Overview
Instance Attribute Summary collapse
-
#content_type ⇒ Object
The content type of the “uploaded” file.
-
#original_filename ⇒ Object
readonly
The filename, not including the path, of the “uploaded” file.
-
#tempfile ⇒ Object
readonly
The tempfile.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content, content_type = 'text/plain', binary = false, original_filename: nil) ⇒ UploadedFile
constructor
Creates a new UploadedFile instance.
-
#method_missing(method_name, *args, &block) ⇒ Object
:nodoc:.
- #path ⇒ Object (also: #local_path)
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
:nodoc:.
Constructor Details
#initialize(content, content_type = 'text/plain', binary = false, original_filename: nil) ⇒ UploadedFile
Creates a new UploadedFile instance.
30 31 32 33 34 35 36 37 38 |
# File 'lib/rack/test/uploaded_file.rb', line 30 def initialize(content, content_type = 'text/plain', binary = false, original_filename: nil) if original_filename initialize_from_stringio(content, original_filename) else initialize_from_file_path(content) end @content_type = content_type @tempfile.binmode if binary end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
:nodoc:
46 47 48 |
# File 'lib/rack/test/uploaded_file.rb', line 46 def method_missing(method_name, *args, &block) #:nodoc: tempfile.public_send(method_name, *args, &block) end |
Instance Attribute Details
#content_type ⇒ Object
The content type of the “uploaded” file
20 21 22 |
# File 'lib/rack/test/uploaded_file.rb', line 20 def content_type @content_type end |
#original_filename ⇒ Object (readonly)
The filename, not including the path, of the “uploaded” file
14 15 16 |
# File 'lib/rack/test/uploaded_file.rb', line 14 def original_filename @original_filename end |
#tempfile ⇒ Object (readonly)
The tempfile
17 18 19 |
# File 'lib/rack/test/uploaded_file.rb', line 17 def tempfile @tempfile end |
Class Method Details
.actually_finalize(file) ⇒ Object
58 59 60 61 |
# File 'lib/rack/test/uploaded_file.rb', line 58 def self.actually_finalize(file) file.close file.unlink end |
.finalize(file) ⇒ Object
54 55 56 |
# File 'lib/rack/test/uploaded_file.rb', line 54 def self.finalize(file) proc { actually_finalize file } end |
Instance Method Details
#path ⇒ Object Also known as: local_path
40 41 42 |
# File 'lib/rack/test/uploaded_file.rb', line 40 def path tempfile.path end |
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
:nodoc:
50 51 52 |
# File 'lib/rack/test/uploaded_file.rb', line 50 def respond_to_missing?(method_name, include_private = false) #:nodoc: tempfile.respond_to?(method_name, include_private) || super end |