Class: Trane::Docs::ServiceDefinition
- Inherits:
-
Object
- Object
- Trane::Docs::ServiceDefinition
- Defined in:
- lib/trane/docs/service_definition.rb
Class Method Summary collapse
-
.generate(routes, service_name:) ⇒ Hash
Generate a complete service definition hash from the registry and routes.
Instance Method Summary collapse
-
#initialize(routes, service_name:) ⇒ ServiceDefinition
constructor
A new instance of ServiceDefinition.
- #to_h ⇒ Object
Constructor Details
#initialize(routes, service_name:) ⇒ ServiceDefinition
Returns a new instance of ServiceDefinition.
19 20 21 22 23 |
# File 'lib/trane/docs/service_definition.rb', line 19 def initialize(routes, service_name:) @routes = routes @service_name = service_name @registry = Trane.registry end |
Class Method Details
.generate(routes, service_name:) ⇒ Hash
Generate a complete service definition hash from the registry and routes.
15 16 17 |
# File 'lib/trane/docs/service_definition.rb', line 15 def self.generate(routes, service_name:) new(routes, service_name: service_name).to_h end |
Instance Method Details
#to_h ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/trane/docs/service_definition.rb', line 25 def to_h { service: { name: @service_name }, operations: build_operations, representations: build_representations, errors: build_errors } end |