Class: Bifrossht::Config::Connection

Inherits:
Element
  • Object
show all
Defined in:
lib/bifrossht/config/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Connection

Returns a new instance of Connection.


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/bifrossht/config/connection.rb', line 4

def initialize(options = {})
  super

  validate_presence 'type', 'name'
  validate_type 'type', String
  validate_type 'name', String
  validate_boolean 'skip_probe'
  validate_type 'parameters', Hash
  validate_type 'match', Array
  validate_type 'match_addr', Array
end

Instance Method Details

#matchObject


32
33
34
35
36
# File 'lib/bifrossht/config/connection.rb', line 32

def match
  return [] if @options['match'].nil?

  @options['match'].map { |re| Regexp.new re }
end

#match_addrObject


38
39
40
41
42
# File 'lib/bifrossht/config/connection.rb', line 38

def match_addr
  return [] if @options['match_addr'].nil?

  @options['match_addr'].map { |ip| IPAddr.new ip }
end

#nameObject


20
21
22
# File 'lib/bifrossht/config/connection.rb', line 20

def name
  @options['name']
end

#parametersObject


28
29
30
# File 'lib/bifrossht/config/connection.rb', line 28

def parameters
  @options['parameters'] || {}
end

#skip_probeObject


24
25
26
# File 'lib/bifrossht/config/connection.rb', line 24

def skip_probe
  @options['skip_probe'] || false
end

#typeObject


16
17
18
# File 'lib/bifrossht/config/connection.rb', line 16

def type
  @options['type']
end