Class: Rack::Chunker

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/chunker.rb,
lib/rack/chunker/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Instance Method Summary collapse

Constructor Details

#initialize(stack, bitsize = false) ⇒ Chunker

Returns a new instance of Chunker.



8
9
10
11
# File 'lib/rack/chunker.rb', line 8

def initialize(stack, bitsize = false)
  @stack = stack
  @bitsize = bitsize
end

Instance Method Details

#call(previous_state) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/rack/chunker.rb', line 13

def call(previous_state)
  @state = previous_state
  @status, @headers, @body = stack.call(state)

  if body.is_a?(Array)
    [status, headers, body]
  else
    [status, headers, [body]]
  end
end