Class: SC::Rack::DeferrableBody
- Includes:
- EM::Deferrable
- Defined in:
- lib/sproutcore/rack/proxy.rb
Instance Method Summary collapse
- #call(body) ⇒ Object
- #each(&blk) ⇒ Object
-
#initialize(options = {}) ⇒ DeferrableBody
constructor
A new instance of DeferrableBody.
- #prepare_chunk(chunk) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DeferrableBody
Returns a new instance of DeferrableBody.
37 38 39 |
# File 'lib/sproutcore/rack/proxy.rb', line 37 def initialize( = {}) @options = end |
Instance Method Details
#call(body) ⇒ Object
41 42 43 44 45 |
# File 'lib/sproutcore/rack/proxy.rb', line 41 def call(body) body.each do |chunk| @body_callback.call(prepare_chunk(chunk)) end end |
#each(&blk) ⇒ Object
57 58 59 |
# File 'lib/sproutcore/rack/proxy.rb', line 57 def each(&blk) @body_callback = blk end |
#prepare_chunk(chunk) ⇒ Object
47 48 49 50 51 52 53 54 55 |
# File 'lib/sproutcore/rack/proxy.rb', line 47 def prepare_chunk(chunk) if chunked? size = chunk.respond_to?(:bytesize) ? chunk.bytesize : chunk.length "#{size.to_s(16)}\r\n#{chunk}\r\n" else # Thin doesn't like null bodies chunk || '' end end |