Class: ForemanMaintain::Utils::Service::Abstract

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/foreman_maintain/utils/service/abstract.rb

Direct Known Subclasses

RemoteDB, Systemd

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, priority, options = {}) ⇒ Abstract

Returns a new instance of Abstract.



7
8
9
10
11
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 7

def initialize(name, priority, options = {})
  @name = name
  @priority = priority
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 5

def name
  @name
end

#priorityObject (readonly)

Returns the value of attribute priority.



5
6
7
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 5

def priority
  @priority
end

Instance Method Details

#<=>(other) ⇒ Object



19
20
21
22
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 19

def <=>(other)
  prio_cmp = @priority <=> other.priority
  (prio_cmp == 0) ? @name <=> other.name : prio_cmp
end

#disableObject

Raises:

  • (NotImplementedError)


62
63
64
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 62

def disable
  raise NotImplementedError
end

#enableObject

Raises:

  • (NotImplementedError)


58
59
60
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 58

def enable
  raise NotImplementedError
end

#exist?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


42
43
44
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 42

def exist?
  raise NotImplementedError
end

#inspectObject



28
29
30
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 28

def inspect
  "#{self.class.name.split('::').last}(#{@name} [#{@priority}])"
end

#matches?(service) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 32

def matches?(service)
  if service.is_a? String
    service == @name
  elsif service.instance_of?(self.class)
    service.name == @name
  else
    false
  end
end

#running?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


66
67
68
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 66

def running?
  raise NotImplementedError
end

#socketObject



13
14
15
16
17
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 13

def socket
  if @options[:socket]
    self.class.new("#{@options[:socket]}.socket", priority)
  end
end

#startObject

Raises:

  • (NotImplementedError)


50
51
52
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 50

def start
  raise NotImplementedError
end

#statusObject

Raises:

  • (NotImplementedError)


46
47
48
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 46

def status
  raise NotImplementedError
end

#stopObject

Raises:

  • (NotImplementedError)


54
55
56
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 54

def stop
  raise NotImplementedError
end

#to_sObject



24
25
26
# File 'lib/foreman_maintain/utils/service/abstract.rb', line 24

def to_s
  @name
end