Class: Hcheck::Configuration::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/hcheck/configuration/service.rb

Overview

Main service class One to one servcie class is created from hcheck.yml top level keys includes corresponsing check module; which includes status method

Constant Summary collapse

NOT_IMPLEMENTED_MSG =
'Check not implemented for this service'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, options) ⇒ Service

Returns a new instance of Service.



18
19
20
21
22
23
24
25
26
27
# File 'lib/hcheck/configuration/service.rb', line 18

def initialize(service, options)
  @name = service.to_s
  @check = options.delete('check')
  @options = options.symbolize_keys
  if mod = load_mod
    singleton_class.send(:include, mod)
  else
    @check_not_available = true
  end
end

Instance Attribute Details

#check_not_availableObject (readonly)

Returns the value of attribute check_not_available.



14
15
16
# File 'lib/hcheck/configuration/service.rb', line 14

def check_not_available
  @check_not_available
end

#nameObject (readonly)

Returns the value of attribute name.



14
15
16
# File 'lib/hcheck/configuration/service.rb', line 14

def name
  @name
end

Instance Method Details

#checkObject



29
30
31
32
33
34
35
# File 'lib/hcheck/configuration/service.rb', line 29

def check
  {
    name: @name,
    desc: @check,
    status: @check_not_available ? NOT_IMPLEMENTED_MSG : check_status
  }
end