Class: Kumonos::Routes::Vhost

Inherits:
Struct
  • Object
show all
Defined in:
lib/kumonos/routes.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#domainsObject

Returns the value of attribute domains

Returns:

  • (Object)

    the current value of domains



13
14
15
# File 'lib/kumonos/routes.rb', line 13

def domains
  @domains
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



13
14
15
# File 'lib/kumonos/routes.rb', line 13

def name
  @name
end

#routesObject

Returns the value of attribute routes

Returns:

  • (Object)

    the current value of routes



13
14
15
# File 'lib/kumonos/routes.rb', line 13

def routes
  @routes
end

Class Method Details

.build(h) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/kumonos/routes.rb', line 15

def build(h)
  name = h.fetch('name')
  cluster_name = h.fetch('cluster_name')
  host_header = h['host_header']
  routes = h.fetch('routes').map { |r| Route.build(r, cluster_name, host_header) }
  new(name, [name], routes)
end

Instance Method Details

#to_hObject



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/kumonos/routes.rb', line 24

def to_h
  h = super
  h[:routes] = routes.flat_map do |r|
    # i.e. retry with gRPC request (HTTP POST)
    if r.method
      [r.to_h_with_retry]
    else
      [r.to_h_with_retry, r.to_h]
    end
  end
  h
end