Class: Metatron::Templates::GRPCRoute::Filter
- Inherits:
-
Object
- Object
- Metatron::Templates::GRPCRoute::Filter
- 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
-
#config ⇒ Object
Returns the value of attribute config.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(type:, **config) ⇒ Filter
constructor
A new instance of Filter.
- #render ⇒ Object
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
#config ⇒ Object
Returns the value of attribute config.
20 21 22 |
# File 'lib/metatron/templates/grpc_route/filter.rb', line 20 def config @config end |
#type ⇒ Object
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
#render ⇒ Object
27 28 29 |
# File 'lib/metatron/templates/grpc_route/filter.rb', line 27 def render { type: }.merge(config.empty? ? {} : { type_key => config }) end |