Class: Mackerel::Annotation
- Inherits:
-
Object
- Object
- Mackerel::Annotation
- Defined in:
- lib/mackerel/annotation.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#from ⇒ Object
Returns the value of attribute from.
-
#id ⇒ Object
Returns the value of attribute id.
-
#roles ⇒ Object
Returns the value of attribute roles.
-
#service ⇒ Object
Returns the value of attribute service.
-
#title ⇒ Object
Returns the value of attribute title.
-
#to ⇒ Object
Returns the value of attribute to.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Annotation
constructor
A new instance of Annotation.
- #to_h ⇒ Object
- #to_json(options = nil) ⇒ Object
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
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def description @description end |
#from ⇒ Object
Returns the value of attribute from.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def from @from end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def id @id end |
#roles ⇒ Object
Returns the value of attribute roles.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def roles @roles end |
#service ⇒ Object
Returns the value of attribute service.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def service @service end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def title @title end |
#to ⇒ Object
Returns the value of attribute to.
4 5 6 |
# File 'lib/mackerel/annotation.rb', line 4 def to @to end |
Instance Method Details
#to_h ⇒ Object
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( = nil) return to_h.to_json() end |