Class: Rack::FileUpload
- Inherits:
-
Object
- Object
- Rack::FileUpload
- Defined in:
- lib/rack/file_upload.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ FileUpload
constructor
A new instance of FileUpload.
- #upload_path?(request_path) ⇒ Boolean
Constructor Details
#initialize(app, options = {}) ⇒ FileUpload
Returns a new instance of FileUpload.
8 9 10 11 12 13 14 |
# File 'lib/rack/file_upload.rb', line 8 def initialize(app, ={}) @app = app @paths = [[:upload_dir]] @explicit = [:explicit] @tmpdir = [:tmp_dir] || Dir::tmpdir @paths = [@paths] if @paths.kind_of?(String) end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 |
# File 'lib/rack/file_upload.rb', line 16 def call(env) kick_in?(env) ? convert_and_pass_on(env) : @app.call(env) end |
#upload_path?(request_path) ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/rack/file_upload.rb', line 20 def upload_path?(request_path) return true if @paths.nil? @paths.any? do |candidate| literal_path_match?(request_path, candidate) || wildcard_path_match?(request_path, candidate) end end |