Class: Metatron::Templates::Gateway::Listener

Inherits:
Object
  • Object
show all
Defined in:
lib/metatron/templates/gateway/listener.rb

Overview

Internal model for a Gateway listener

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, port:, protocol:, hostname: nil, tls: nil, allowed_routes: nil) ⇒ Listener

Returns a new instance of Listener.



10
11
12
13
14
15
16
17
# File 'lib/metatron/templates/gateway/listener.rb', line 10

def initialize(name, port:, protocol:, hostname: nil, tls: nil, allowed_routes: nil)
  @name = name
  @port = port
  @protocol = protocol
  @hostname = hostname
  @tls = tls
  @allowed_routes = allowed_routes
end

Instance Attribute Details

#allowed_routesObject

Returns the value of attribute allowed_routes.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def allowed_routes
  @allowed_routes
end

#hostnameObject

Returns the value of attribute hostname.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def hostname
  @hostname
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def name
  @name
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def port
  @port
end

#protocolObject

Returns the value of attribute protocol.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def protocol
  @protocol
end

#tlsObject

Returns the value of attribute tls.



8
9
10
# File 'lib/metatron/templates/gateway/listener.rb', line 8

def tls
  @tls
end

Instance Method Details

#renderObject



19
20
21
22
23
24
# File 'lib/metatron/templates/gateway/listener.rb', line 19

def render
  { name:, port:, protocol: }
    .merge(hostname ? { hostname: } : {})
    .merge(tls ? { tls: } : {})
    .merge(allowed_routes ? { allowedRoutes: allowed_routes } : {})
end