Class: QueryGuard::Middleware::BodyProxy

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

Instance Method Summary collapse

Constructor Details

#initialize(body, stats) ⇒ BodyProxy

Returns a new instance of BodyProxy.



10
11
12
13
# File 'lib/query_guard/middleware.rb', line 10

def initialize(body, stats)
  @body = body
  @stats = stats
end

Instance Method Details

#close ⇒ Object



22
23
24
# File 'lib/query_guard/middleware.rb', line 22

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

#each ⇒ Object



15
16
17
18
19
20
# File 'lib/query_guard/middleware.rb', line 15

def each
  @body.each do |chunk|
    @stats[:response_bytes] += chunk.to_s.bytesize
    yield chunk
  end
end