Class: Metatron::Templates::HTTPRoute::Filter
- Inherits:
-
Object
- Object
- Metatron::Templates::HTTPRoute::Filter
- Defined in:
- lib/metatron/templates/http_route/filter.rb
Overview
Internal model for an HTTPRoute filter.
The type must be the canonical CamelCase name (e.g. "URLRewrite",
"RequestHeaderModifier"). All remaining keyword arguments become the
type-specific configuration nested under the auto-derived camelCase key.
Example:
Filter.new(
type: "URLRewrite",
hostname: "example.net",
path: { type: "ReplacePrefixMatch", replacePrefixMatch: "/new-prefix" }
)
# => { type: "URLRewrite", urlRewrite: { hostname: "example.net", path: { ... } } }
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.
21 22 23 24 |
# File 'lib/metatron/templates/http_route/filter.rb', line 21 def initialize(type:, **config) @type = type @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
19 20 21 |
# File 'lib/metatron/templates/http_route/filter.rb', line 19 def config @config end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/metatron/templates/http_route/filter.rb', line 19 def type @type end |
Instance Method Details
#render ⇒ Object
26 27 28 |
# File 'lib/metatron/templates/http_route/filter.rb', line 26 def render { type: }.merge(config.empty? ? {} : { type_key => config }) end |