Class: Mackerel::Alert

Inherits:
Object
  • Object
show all
Defined in:
lib/mackerel/alert.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Alert

Returns a new instance of Alert.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/mackerel/alert.rb', line 6

def initialize(args = {})
  @id                              = args["id"]
  @status                          = args["status"]
  @monitorId                       = args["monitorId"]
  @type                            = args["type"]
  @hostId                          = args["hostId"]
  @value                           = args["value"]
  @message                         = args["message"]
  @reason                          = args["reason"]
  @openedAt                        = args["openedAt"]
  @closedAt                        = args["closedAt"]
end

Instance Attribute Details

#closedAtObject

Returns the value of attribute closedAt.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def closedAt
  @closedAt
end

#hostIdObject

Returns the value of attribute hostId.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def hostId
  @hostId
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def id
  @id
end

#messageObject

Returns the value of attribute message.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def message
  @message
end

#monitorIdObject

Returns the value of attribute monitorId.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def monitorId
  @monitorId
end

#openedAtObject

Returns the value of attribute openedAt.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def openedAt
  @openedAt
end

#reasonObject

Returns the value of attribute reason.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def reason
  @reason
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def status
  @status
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def type
  @type
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/mackerel/alert.rb', line 4

def value
  @value
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
25
# File 'lib/mackerel/alert.rb', line 19

def to_h
  instance_variables.flat_map do |name|
    respond_to?(name[1..-1]) ? [name[1..-1]] : []
  end.each_with_object({}) do |name, hash|
    hash[name] = public_send(name)
  end.delete_if { |key, val| val == nil }
end

#to_json(options = nil) ⇒ Object



27
28
29
# File 'lib/mackerel/alert.rb', line 27

def to_json(options = nil)
  return to_h.to_json(options)
end