Class: StatusCheck::Services::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/status_check/services/abstract.rb

Direct Known Subclasses

ActiveRecordSql, BlockResult, Redis

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Abstract

Returns a new instance of Abstract.



6
7
8
# File 'lib/status_check/services/abstract.rb', line 6

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



4
5
6
# File 'lib/status_check/services/abstract.rb', line 4

def connection
  @connection
end

Instance Method Details

#commandObject

Raises:

  • (NotImplementedError)


10
11
12
# File 'lib/status_check/services/abstract.rb', line 10

def command
  raise NotImplementedError, "Check command have to be defined"
end

#report_statusObject



20
21
22
23
24
25
# File 'lib/status_check/services/abstract.rb', line 20

def report_status
  command_result = command
  status_hash(command_result)
rescue StandardError => exception
  status_hash(command_result, exception)
end

#status_message(command_result, exception = nil) ⇒ Object



14
15
16
17
18
# File 'lib/status_check/services/abstract.rb', line 14

def status_message(command_result, exception = nil)
  return exception.to_s if !command_result && exception
  return 'FAILED' if !command_result
  'OK'
end