Class: Mackerel::Service
- Inherits:
-
Object
- Object
- Mackerel::Service
- Defined in:
- lib/mackerel/service.rb
Instance Attribute Summary collapse
-
#memo ⇒ Object
Returns the value of attribute memo.
-
#name ⇒ Object
Returns the value of attribute name.
-
#roles ⇒ Object
Returns the value of attribute roles.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Service
constructor
A new instance of Service.
- #to_h ⇒ Object
- #to_json(options = nil) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Service
Returns a new instance of Service.
7 8 9 10 11 |
# File 'lib/mackerel/service.rb', line 7 def initialize(args = {}) @name = args["name"] @memo = args["memo"] @roles = args["roles"] end |
Instance Attribute Details
#memo ⇒ Object
Returns the value of attribute memo.
5 6 7 |
# File 'lib/mackerel/service.rb', line 5 def memo @memo end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/mackerel/service.rb', line 5 def name @name end |
#roles ⇒ Object
Returns the value of attribute roles.
5 6 7 |
# File 'lib/mackerel/service.rb', line 5 def roles @roles end |
Instance Method Details
#to_h ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/mackerel/service.rb', line 13 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
21 22 23 |
# File 'lib/mackerel/service.rb', line 21 def to_json( = nil) return to_h.to_json() end |