Class: HaproxyParser::Builders::Backend

Inherits:
Base
  • Object
show all
Defined in:
lib/haproxy_parser/builders/backend.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#default, #section

Instance Method Summary collapse

Methods inherited from Base

#attributes, #name

Constructor Details

#initialize(section:, default: nil, frontend:) ⇒ Backend

Returns a new instance of Backend.



8
9
10
11
# File 'lib/haproxy_parser/builders/backend.rb', line 8

def initialize(section:, default: nil, frontend:)
  super(section: section, default: default)
  @frontend = frontend
end

Instance Attribute Details

#frontendObject

Returns the value of attribute frontend.



7
8
9
# File 'lib/haproxy_parser/builders/backend.rb', line 7

def frontend
  @frontend
end

Instance Method Details

#balanceObject



17
18
19
# File 'lib/haproxy_parser/builders/backend.rb', line 17

def balance
  @balance ||= dig_data("balance")
end

#modeObject



13
14
15
# File 'lib/haproxy_parser/builders/backend.rb', line 13

def mode
  @mode ||= dig_data("mode")
end

#serversObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/haproxy_parser/builders/backend.rb', line 21

def servers
  @servers ||= [].tap do |arr|
    if line_servers[0].is_a?(Array)
      line_servers.each do |line_server|
        arr << ServerParser.new(
          line: line_server,
          frontend_port: frontend.port
        )
      end
    else
      arr << ServerParser.new(
        line: line_servers,
        frontend_port: frontend.port
      )
    end
  end
end