Module: Metatron::Templates::Concerns::RouteResource
- Defined in:
- lib/metatron/templates/concerns/route_resource.rb
Overview
Provides common parent reference functionality for Gateway API route resources
Class Method Summary collapse
Instance Method Summary collapse
- #add_parent_ref(name:, namespace: nil, kind: "Gateway", section_name: nil, port: nil) ⇒ Object
- #formatted_parent_refs ⇒ Object
- #route_resource_initialize ⇒ Object
Class Method Details
.included(base) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/metatron/templates/concerns/route_resource.rb', line 8 def self.included(base) base.class_eval do attr_reader :parent_refs initializer :route_resource_initialize end end |
Instance Method Details
#add_parent_ref(name:, namespace: nil, kind: "Gateway", section_name: nil, port: nil) ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/metatron/templates/concerns/route_resource.rb', line 20 def add_parent_ref(name:, namespace: nil, kind: "Gateway", section_name: nil, port: nil) ref = { name:, kind: } ref[:namespace] = namespace if namespace ref[:sectionName] = section_name if section_name ref[:port] = port if port @parent_refs << ref end |
#formatted_parent_refs ⇒ Object
28 29 30 |
# File 'lib/metatron/templates/concerns/route_resource.rb', line 28 def formatted_parent_refs parent_refs.empty? ? {} : { parentRefs: parent_refs } end |
#route_resource_initialize ⇒ Object
16 17 18 |
# File 'lib/metatron/templates/concerns/route_resource.rb', line 16 def route_resource_initialize @parent_refs = [] end |