Class: Rack::Maintenance
- Inherits:
-
Object
- Object
- Rack::Maintenance
- Defined in:
- lib/rack/maintenance/version.rb,
lib/rack/maintenance.rb
Constant Summary collapse
- VERSION =
"3.0.0"
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
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.
7 8 9 10 11 12 |
# File 'lib/rack/maintenance.rb', line 7 def initialize(app, ={}) @app = app @options = raise(ArgumentError, 'Must specify a :file') unless [:file] end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
5 6 7 |
# File 'lib/rack/maintenance.rb', line 5 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/rack/maintenance.rb', line 5 def @options end |
Instance Method Details
#call(env) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/maintenance.rb', line 14 def call(env) if maintenance? && path_in_app(env) content = File.read(file) data = processor.call(content) [ 503, { 'Content-Type' => content_type, 'Content-Length' => data.bytesize.to_s }, [data] ] else app.call(env) end end |