Class: Garner::Middleware::Base
- Inherits:
-
Object
- Object
- Garner::Middleware::Base
- Defined in:
- lib/garner/middleware/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#after ⇒ Response?
abstract
Called after the application is called in the middleware lifecycle.
-
#before ⇒ Object
abstract
Called before the application is called in the middleware lifecycle.
- #call(env) ⇒ Object
- #call!(env) ⇒ Object
- #default_options ⇒ Object
-
#initialize(app, options = {}) ⇒ Base
constructor
A new instance of Base.
- #request ⇒ Object
- #response ⇒ Object
Constructor Details
#initialize(app, options = {}) ⇒ Base
Returns a new instance of Base.
9 10 11 12 |
# File 'lib/garner/middleware/base.rb', line 9 def initialize(app, = {}) @app = app @options = .merge() end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/garner/middleware/base.rb', line 5 def app @app end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
5 6 7 |
# File 'lib/garner/middleware/base.rb', line 5 def env @env end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/garner/middleware/base.rb', line 5 def @options end |
Instance Method Details
#after ⇒ Response?
This method is abstract.
Called after the application is called in the middleware lifecycle.
34 |
# File 'lib/garner/middleware/base.rb', line 34 def after; end |
#before ⇒ Object
This method is abstract.
Called before the application is called in the middleware lifecycle.
29 |
# File 'lib/garner/middleware/base.rb', line 29 def before; end |
#call(env) ⇒ Object
16 17 18 |
# File 'lib/garner/middleware/base.rb', line 16 def call(env) dup.call!(env) end |
#call!(env) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/garner/middleware/base.rb', line 20 def call!(env) @env = env before @app_response = @app.call(@env) after || @app_response end |
#default_options ⇒ Object
14 |
# File 'lib/garner/middleware/base.rb', line 14 def ; {} end |
#request ⇒ Object
36 37 38 |
# File 'lib/garner/middleware/base.rb', line 36 def request Rack::Request.new(self.env) end |
#response ⇒ Object
40 41 42 |
# File 'lib/garner/middleware/base.rb', line 40 def response Rack::Response.new(@app_response) end |