Class: Metatron::Templates::GRPCRoute::Filter

Inherits:
Object
  • Object
show all
Defined in:
lib/metatron/templates/grpc_route/filter.rb

Overview

Internal model for a GRPCRoute filter. The type must be the canonical CamelCase name (e.g. "RequestHeaderModifier", "ResponseHeaderModifier", "RequestMirror", "ExtensionRef"). All remaining keyword arguments become the type-specific configuration nested under the auto-derived camelCase key.

Example:

Filter.new(
type: "RequestHeaderModifier",
add: [{ name: "X-Custom-Header", value: "custom-value" }]
)
# => { type: "RequestHeaderModifier",
#      requestHeaderModifier: { add: [{ ... }] } }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, **config) ⇒ Filter

Returns a new instance of Filter.



22
23
24
25
# File 'lib/metatron/templates/grpc_route/filter.rb', line 22

def initialize(type:, **config)
  @type = type
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



20
21
22
# File 'lib/metatron/templates/grpc_route/filter.rb', line 20

def config
  @config
end

#typeObject

Returns the value of attribute type.



20
21
22
# File 'lib/metatron/templates/grpc_route/filter.rb', line 20

def type
  @type
end

Instance Method Details

#renderObject



27
28
29
# File 'lib/metatron/templates/grpc_route/filter.rb', line 27

def render
  { type: }.merge(config.empty? ? {} : { type_key => config })
end