Class: Rack::Maintenance
- Inherits:
-
Object
- Object
- Rack::Maintenance
- Defined in:
- lib/rack/maintenance.rb
Defined Under Namespace
Classes: InvalidStatus
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ Maintenance
constructor
A new instance of Maintenance.
Constructor Details
#initialize(app, options = {}) ⇒ Maintenance
Returns a new instance of Maintenance.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rack/maintenance.rb', line 6 def initialize(app, = {}) raise InvalidStatus if [:status] && [:status].to_i < 100 @app = app @status = [:status] || default_status @headers = [:headers] || default_headers @template = [:template] || default_template @active = [:active].nil? ? true : [:active] end |
Instance Method Details
#call(env) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rack/maintenance.rb', line 17 def call(env) if active? headers['Content-Length'] = body.bytesize.to_s return [status, headers, [body]] end @app.call(env) end |