Class: Fisher::Rack::Middleware::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/fisher/rack/middleware.rb

Overview

Body wrapper. Yields to the block when body is closed. This is used to signal when a response is fully finished processing.

Instance Method Summary collapse

Constructor Details

#initialize(body, &block) ⇒ Body

Returns a new instance of Body.



78
79
80
81
# File 'lib/fisher/rack/middleware.rb', line 78

def initialize(body, &block)
  @body = body
  @block = block
end

Instance Method Details

#closeObject



91
92
93
94
95
# File 'lib/fisher/rack/middleware.rb', line 91

def close
  @body.close if @body.respond_to?(:close)
  @block.call
  nil
end

#each(&block) ⇒ Object



83
84
85
86
87
88
89
# File 'lib/fisher/rack/middleware.rb', line 83

def each(&block)
  if @body.respond_to?(:each)
    @body.each(&block)
  else
    block.call(@body)
  end
end