123456789_123456789_123456789_123456789_123456789_

Class: Rack::Events::EventedBodyProxy

Do not use. This class is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, BodyProxy
Instance Chain:
self, BodyProxy
Inherits: Rack::BodyProxy
Defined in: lib/rack/events.rb

Class Method Summary

BodyProxy - Inherited

.new

Set the response body to wrap, and the block to call when the response has been fully sent.

Instance Attribute Summary

BodyProxy - Inherited

#closed?

Whether the proxy is closed.

Instance Method Summary

BodyProxy - Inherited

#close

If not already closed, close the wrapped body and then call the block the proxy was initialized with.

#method_missing

Delegate missing methods to the wrapped body.

#respond_to_missing?

Return whether the wrapped body responds to the method.

Constructor Details

.new(body, request, response, handlers, &block) ⇒ EventedBodyProxy

[ GitHub ]

  
# File 'lib/rack/events.rb', line 83

def initialize(body, request, response, handlers, &block)
  super(body, &block)
  @request  = request
  @response = response
  @handlers = handlers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rack::BodyProxy

Instance Attribute Details

#request (readonly)

[ GitHub ]

  
# File 'lib/rack/events.rb', line 81

attr_reader :request, :response

#response (readonly)

[ GitHub ]

  
# File 'lib/rack/events.rb', line 81

attr_reader :request, :response

Instance Method Details

#call(stream)

[ GitHub ]

  
# File 'lib/rack/events.rb', line 95

def call(stream)
  @handlers.reverse_each { |handler| handler.on_send request, response }
  super
end

#each

[ GitHub ]

  
# File 'lib/rack/events.rb', line 90

def each
  @handlers.reverse_each { |handler| handler.on_send request, response }
  super
end

#respond_to?(method_name, include_all = false) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rack/events.rb', line 100

def respond_to?(method_name, include_all = false)
  case method_name
  when :each, :call
    @body.respond_to?(method_name, include_all)
  else
    super
  end
end