Class: JefferiesTube::Rack::Maintenance

Inherits:
Object
  • Object
show all
Defined in:
lib/jefferies_tube/rack/maintenance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Maintenance

Returns a new instance of Maintenance.



8
9
10
11
# File 'lib/jefferies_tube/rack/maintenance.rb', line 8

def initialize(app, options={})
  @app     = app
  @options = options
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



6
7
8
# File 'lib/jefferies_tube/rack/maintenance.rb', line 6

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/jefferies_tube/rack/maintenance.rb', line 6

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
# File 'lib/jefferies_tube/rack/maintenance.rb', line 13

def call(env)
  message = File.read('./tmp/maintenance.txt')
  message = "Sorry, this site is down for maintenance." if message.empty?
  [ 503, { "Content-Type" => "text/plain", "Content-Length" => message.bytesize.to_s }, [message] ]
end