Class: Mackerel::Organization

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/mackerel/organization.rb', line 3

def name
  @name
end

Instance Method Details

#to_hObject



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(options = nil)
  return to_h.to_json(options)
end