Class: Rack::Healthz::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/healthz/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(accumulator) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/rack/healthz/response.rb', line 6

def initialize(accumulator)
  @accumulator = accumulator
end

Instance Attribute Details

#accumulatorObject (readonly)

Returns the value of attribute accumulator.



4
5
6
# File 'lib/rack/healthz/response.rb', line 4

def accumulator
  @accumulator
end

Instance Method Details

#content_typeObject



22
23
24
# File 'lib/rack/healthz/response.rb', line 22

def content_type
  ContentType
end

#healthy?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rack/healthz/response.rb', line 26

def healthy?
  accumulator.healthy?
end

#return_statusObject



30
31
32
33
34
35
36
# File 'lib/rack/healthz/response.rb', line 30

def return_status
  if healthy?
    HealthyStatus
  else
    UnhealthyStatus
  end
end

#to_aObject



10
11
12
# File 'lib/rack/healthz/response.rb', line 10

def to_a
  [return_status, content_type, [to_json]]
end

#to_hObject



18
19
20
# File 'lib/rack/healthz/response.rb', line 18

def to_h
  accumulator.to_h
end

#to_jsonObject



14
15
16
# File 'lib/rack/healthz/response.rb', line 14

def to_json
  to_h.to_json
end