Class: Wellness::Services::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/wellness/services/base.rb

Overview

Author:

  • Matthew A. Johnston

Direct Known Subclasses

PostgresService, RedisService, SidekiqService

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = {}) ⇒ Base

Returns a new instance of Base.

Parameters:

  • params (Hash) (defaults to: {})

15
16
17
18
19
# File 'lib/wellness/services/base.rb', line 15

def initialize(name, params={})
  @name = name
  @params = params
  @result = {}
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.


5
6
7
# File 'lib/wellness/services/base.rb', line 5

def name
  @name
end

#paramsObject (readonly)

Returns the value of attribute params.


5
6
7
# File 'lib/wellness/services/base.rb', line 5

def params
  @params
end

#resultObject (readonly)

Returns the value of attribute result.


5
6
7
# File 'lib/wellness/services/base.rb', line 5

def result
  @result
end

Class Method Details

.dependencyObject

Load dependencies when the class is loaded. This makes putting requires at the top of the file unnecessary. It plays nicely with the auto loader.


10
11
12
# File 'lib/wellness/services/base.rb', line 10

def self.dependency
  yield if block_given?
end

Instance Method Details

#callWellness::Services::Base


36
37
38
39
# File 'lib/wellness/services/base.rb', line 36

def call
  @result = self.check
  self
end

#checkHash

Returns:

  • (Hash)

42
43
44
45
46
# File 'lib/wellness/services/base.rb', line 42

def check
  {
    status: 'UNHEALTHY'
  }
end

#failed_checkObject


31
32
33
# File 'lib/wellness/services/base.rb', line 31

def failed_check
  warn('#failed_check has been deprecated')
end

#healthy?TrueClass, FalseClass

Returns true if the service is healthy, otherwise false

Returns:

  • (TrueClass, FalseClass)

23
24
25
# File 'lib/wellness/services/base.rb', line 23

def healthy?
  @result.fetch(:status, 'UNHEALTHY') == 'HEALTHY'
end

#passed_checkObject


27
28
29
# File 'lib/wellness/services/base.rb', line 27

def passed_check
  warn('#passed_check has been deprecated')
end