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