Class: MiniCheck::RackApp
- Inherits:
-
Object
- Object
- MiniCheck::RackApp
- Defined in:
- lib/mini_check/rack_app.rb
Constant Summary collapse
- CONTENT_TYPE_HEADER =
'Content-Type'.freeze
- JSON_MIME_TYPE =
'application/json'.freeze
- REQUEST_METHOD =
'REQUEST_METHOD'.freeze
- PATH_INFO =
'PATH_INFO'.freeze
Instance Attribute Summary collapse
-
#checks ⇒ Object
Returns the value of attribute checks.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(args = {}) ⇒ RackApp
constructor
A new instance of RackApp.
- #new(app) ⇒ Object
- #register(name, &block) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ RackApp
11 12 13 |
# File 'lib/mini_check/rack_app.rb', line 11 def initialize args = {} set_attributes args end |
Instance Attribute Details
#checks ⇒ Object
Returns the value of attribute checks.
3 4 5 |
# File 'lib/mini_check/rack_app.rb', line 3 def checks @checks end |
#path ⇒ Object
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
19 20 21 22 23 24 25 26 27 |
# File 'lib/mini_check/rack_app.rb', line 19 def call env case "#{env[REQUEST_METHOD]} #{env[PATH_INFO]}" when "GET #{path}" checks.run [status, default_headers, [body]] else host_app.call(env) end end |
#new(app) ⇒ Object
33 34 35 36 37 |
# File 'lib/mini_check/rack_app.rb', line 33 def new(app) dup.tap do |copy| copy.host_app = app end end |
#register(name, &block) ⇒ Object
29 30 31 |
# File 'lib/mini_check/rack_app.rb', line 29 def register name, &block checks.register name, &block end |