Class: Pingable::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/pingable/handler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = nil) ⇒ Handler

Returns a new instance of Handler.



5
6
7
# File 'lib/pingable/handler.rb', line 5

def initialize(name = nil)
  @name = name
end

Class Method Details

.call(env) ⇒ Object



9
10
11
# File 'lib/pingable/handler.rb', line 9

def self.call(env)
  new.call(env)
end

Instance Method Details

#call(env) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/pingable/handler.rb', line 13

def call(env)
  failures = Pingable.run_checks!
  if failures.any?
    [503, HEADERS, [failures.map { |f| f[:message] }.join("\n")]]
  else
    [200, HEADERS, [(@name ||= '').dup]]
  end
end