Class: Mackerel::Annotation

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Annotation

Returns a new instance of Annotation.



5
6
7
8
9
10
11
12
13
# File 'lib/mackerel/annotation.rb', line 5

def initialize(args = {})
  @id                              = args["id"]
  @service                         = args["service"]
  @from                            = args["from"]
  @to                              = args["to"]
  @description                     = args["description"]
  @title                           = args["title"]
  @roles                           = args["roles"]
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#fromObject

Returns the value of attribute from.



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

def from
  @from
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#rolesObject

Returns the value of attribute roles.



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

def roles
  @roles
end

#serviceObject

Returns the value of attribute service.



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

def service
  @service
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#toObject

Returns the value of attribute to.



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

def to
  @to
end

Instance Method Details

#to_hObject



15
16
17
18
19
20
21
# File 'lib/mackerel/annotation.rb', line 15

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



23
24
25
# File 'lib/mackerel/annotation.rb', line 23

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