Class: RackAfterReply::AppProxy
- Inherits:
-
Object
- Object
- RackAfterReply::AppProxy
- Defined in:
- lib/rack_after_reply/app_proxy.rb
Overview
Wraps a Rack app to intercept the rack environment passed to #call for access by the request handler after the socket is closed.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(request_handler, app) ⇒ AppProxy
constructor
A new instance of AppProxy.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(name, include_private = false) ⇒ Boolean
Constructor Details
#initialize(request_handler, app) ⇒ AppProxy
Returns a new instance of AppProxy.
7 8 9 10 |
# File 'lib/rack_after_reply/app_proxy.rb', line 7 def initialize(request_handler, app) @request_handler = request_handler @app = app end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/rack_after_reply/app_proxy.rb', line 19 def method_missing(name, *args, &block) class_eval <<-EOS def #{name}(*args, &block) @app.#{name}(*args, &block) end EOS send(name, *args, &block) end |
Instance Method Details
#call(env) ⇒ Object
12 13 14 15 16 17 |
# File 'lib/rack_after_reply/app_proxy.rb', line 12 def call(env) callbacks = [] env[RackAfterReply::CALLBACKS_KEY] = callbacks @request_handler.rack_after_reply_callbacks = callbacks @app.call(env) end |
#respond_to?(name, include_private = false) ⇒ Boolean
28 29 30 |
# File 'lib/rack_after_reply/app_proxy.rb', line 28 def respond_to?(name, include_private=false) super || @app.respond_to?(name, include_private) end |