Class: Healthy::ServerIdentity

Inherits:
Object
  • Object
show all
Defined in:
lib/healthy/server_identity.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.identityObject

Returns the value of attribute identity.



5
6
7
# File 'lib/healthy/server_identity.rb', line 5

def identity
  @identity
end

Class Method Details

.establish(string_or_method_name = nil, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/healthy/server_identity.rb', line 6

def establish(string_or_method_name = nil, &block)
  self.identity = if block
    yield
  elsif string_or_method_name.is_a? Symbol
    self.send(string_or_method_name)
  else
    string_or_method_name
  end
  if identity.nil? || identity.empty?
    raise ArgumentError, "server identity cannot be nil or empty"
  end
end

.fqdnObject



23
24
25
26
27
# File 'lib/healthy/server_identity.rb', line 23

def fqdn
  fqdn = `hostname --fqdn`.strip
  fqdn = `hostname`.strip if fqdn == ''
  fqdn
end

.ip_and_portObject

TODO



30
31
# File 'lib/healthy/server_identity.rb', line 30

def ip_and_port
end

.matches?(test) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/healthy/server_identity.rb', line 19

def matches?(test)
  test.nil? || test.empty? || test == identity || test.is_a?(Array) && test.include?(identity)
end