Class: BreezyPDFLite::Interceptor
- Inherits:
-
Object
- Object
- BreezyPDFLite::Interceptor
- Defined in:
- lib/breezy_pdf_lite/interceptor.rb
Overview
Intercept a Rack request, determining if the app’s response should be intercepted or simply returned
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(app, env) ⇒ Interceptor
constructor
A new instance of Interceptor.
Constructor Details
#initialize(app, env) ⇒ Interceptor
Returns a new instance of Interceptor.
9 10 11 12 |
# File 'lib/breezy_pdf_lite/interceptor.rb', line 9 def initialize(app, env) @app = app @env = env end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
7 8 9 |
# File 'lib/breezy_pdf_lite/interceptor.rb', line 7 def app @app end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/breezy_pdf_lite/interceptor.rb', line 7 def env @env end |
Instance Method Details
#call ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/breezy_pdf_lite/interceptor.rb', line 14 def call if (200..299).cover?(app_response_status) # Did the app respond well? Intercept::HTML.new(app_response_body).call # Try to return a PDF else app_response # Bad app response, just send respond with that end end |