Class: MiniCheck::RackApp

Inherits:
Object
  • Object
show all
Defined in:
lib/mini_check/rack_app.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ RackApp

Returns a new instance of RackApp.



6
7
8
# File 'lib/mini_check/rack_app.rb', line 6

def initialize args = {}
  set_attributes args
end

Instance Attribute Details

#checksObject

Returns the value of attribute checks.



3
4
5
# File 'lib/mini_check/rack_app.rb', line 3

def checks
  @checks
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/mini_check/rack_app.rb', line 4

def path
  @path
end

Instance Method Details

#call(env) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/mini_check/rack_app.rb', line 14

def call env
  case "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}"
  when "GET #{path}"
    checks.run
    [status, headers, [body]]
  else
    [404, headers, []]
  end
end

#register(name, &block) ⇒ Object



24
25
26
# File 'lib/mini_check/rack_app.rb', line 24

def register name, &block
  checks.register name, &block
end