Class: DogWatch::Model::Response
- Inherits:
-
Object
- Object
- DogWatch::Model::Response
- Extended by:
- Mixin::Colorize
- Defined in:
- lib/dogwatch/model/response.rb
Overview
Takes DataDog client responses and formats them nicely
Constant Summary collapse
- ERROR =
'400'.freeze
- CREATED =
'200'.freeze
- ACCEPTED =
'202'.freeze
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response, updated = false) ⇒ Response
constructor
A new instance of Response.
- #message ⇒ Object
- #status ⇒ Object
- #to_thor ⇒ Object
Methods included from Mixin::Colorize
Constructor Details
#initialize(response, updated = false) ⇒ Response
Returns a new instance of Response.
21 22 23 24 |
# File 'lib/dogwatch/model/response.rb', line 21 def initialize(response, updated = false) @response = response @updated = updated end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
19 20 21 |
# File 'lib/dogwatch/model/response.rb', line 19 def response @response end |
Instance Method Details
#message ⇒ Object
33 34 35 36 37 38 |
# File 'lib/dogwatch/model/response.rb', line 33 def attrs = @response[1] return attrs['errors'] if attrs.key?('errors') "#{status.to_s.capitalize} monitor #{attrs['name']}"\ " with message #{attrs['message']}" end |
#status ⇒ Object
26 27 28 29 30 31 |
# File 'lib/dogwatch/model/response.rb', line 26 def status return :updated if @updated == true return :created if created? return :error if failed? return :accepted if accepted? end |
#to_thor ⇒ Object
40 41 42 43 44 |
# File 'lib/dogwatch/model/response.rb', line 40 def to_thor action = status text = [action, text, color] end |