Class: Rack::ECG::Check::Result

Inherits:
Struct
  • Object
show all
Defined in:
lib/rack/ecg/check.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



24
25
26
# File 'lib/rack/ecg/check.rb', line 24

def name
  @name
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



24
25
26
# File 'lib/rack/ecg/check.rb', line 24

def status
  @status
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



24
25
26
# File 'lib/rack/ecg/check.rb', line 24

def value
  @value
end

Instance Method Details

#as_jsonHash<Object, Hash<Symbol, Object>>

Format the result as a JSON compatible hash.

Examples:

A HTTP success response

puts result.as_json
# {:http=>{:status=>"ok", :value=>"online"}}

Returns:

  • (Hash<Object, Hash<Symbol, Object>>)

    Result in a hash format.



31
32
33
# File 'lib/rack/ecg/check.rb', line 31

def as_json
  { name => { status: status, value: value } }
end

#to_jsonString

Return the result as a JSON object.

Examples:

A HTTP success response

puts result.to_json
# {"http": {"status": "ok", "value": "online"}}

Returns:

  • (String)

    Result in a JSON object string.



41
42
43
# File 'lib/rack/ecg/check.rb', line 41

def to_json
  JSON.dump(as_json)
end