Class: RackCustomTmpdir
- Inherits:
-
Object
- Object
- RackCustomTmpdir
- Defined in:
- lib/rack_custom_tmpdir.rb,
lib/rack_custom_tmpdir/version.rb
Constant Summary collapse
- BASENAME_PREFIX =
'RackMultipart'- VERSION =
'0.1.0'
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, tmpdir = nil) ⇒ RackCustomTmpdir
constructor
A new instance of RackCustomTmpdir.
Constructor Details
#initialize(app, tmpdir = nil) ⇒ RackCustomTmpdir
Returns a new instance of RackCustomTmpdir.
6 7 8 9 10 11 12 13 |
# File 'lib/rack_custom_tmpdir.rb', line 6 def initialize(app, tmpdir = nil) @app = app @tempfile_factory = lambda do |filename, content_type| basename_suffix = ::File.extname(filename.gsub("\0".freeze, '%00'.freeze)) Tempfile.new([BASENAME_PREFIX, basename_suffix], tmpdir) end end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 |
# File 'lib/rack_custom_tmpdir.rb', line 15 def call(env) env[Rack::RACK_MULTIPART_TEMPFILE_FACTORY] = @tempfile_factory @app.call(env) end |