class Bark::Service

The Service class hits the Status Monit API endpoint

Public Class Methods

new(client) click to toggle source
# File lib/bark/service.rb, line 5
def initialize(client)
  @client = client
  @status = Bark::Status.new client
end

Public Instance Methods

each() click to toggle source

Retrieves the services which Monit has running / is monitoring

@return [Array]

# File lib/bark/service.rb, line 13
def each
  response = @status.current[:monit][:service]
  if response.is_a? Array
      @services = response.map do |service|
       service
      end
  else
    @services = [@hash["monit"]["service"]]
  end
  @services
end

Private Instance Methods

validate(response) click to toggle source
# File lib/bark/service.rb, line 27
def validate(response)
  if response.status_type == :success
    document = Hash.from_xml(response.body)
  else
    fail StandardError, 'An unknown error occurred.'
  end
  document
end