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