Class: Upload
- Inherits:
-
Object
- Object
- Upload
- Includes:
- Mongrel::HttpHandlerPlugin
- Defined in:
- lib/haikulearning_mongrel_upload_progress/init.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Upload
constructor
A new instance of Upload.
- #process(request, response) ⇒ Object
- #request_begins(params) ⇒ Object
- #request_progress(params, clen, total) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Upload
Returns a new instance of Upload.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/haikulearning_mongrel_upload_progress/init.rb', line 8 def initialize( = {}) @path_info = Array([:path_info]) @frequency = [:frequency] || 3 @request_notify = true if [:drb] require 'drb' DRb.start_service Mongrel.const_set :Uploads, DRbObject.new(nil, [:drb]) else Mongrel.const_set :Uploads, Mongrel::UploadProgress.new end Mongrel::Uploads.debug = true if [:debug] end |
Instance Method Details
#process(request, response) ⇒ Object
30 31 32 |
# File 'lib/haikulearning_mongrel_upload_progress/init.rb', line 30 def process(request, response) upload_notify(:finish, request.params) end |
#request_begins(params) ⇒ Object
22 23 24 |
# File 'lib/haikulearning_mongrel_upload_progress/init.rb', line 22 def request_begins(params) upload_notify(:add, params, params[Mongrel::Const::CONTENT_LENGTH].to_i) end |
#request_progress(params, clen, total) ⇒ Object
26 27 28 |
# File 'lib/haikulearning_mongrel_upload_progress/init.rb', line 26 def request_progress(params, clen, total) upload_notify(:mark, params, clen) end |