Class: AsyncapiCable::Dsl::OperationContext
- Inherits:
-
Object
- Object
- AsyncapiCable::Dsl::OperationContext
- Defined in:
- lib/asyncapi_cable/dsl/operation_context.rb
Constant Summary collapse
- KINDS =
%i[subscribe broadcast publish].freeze
Instance Attribute Summary collapse
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#operation_id ⇒ Object
Returns the value of attribute operation_id.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
Instance Method Summary collapse
-
#initialize(kind, summary = nil) ⇒ OperationContext
constructor
A new instance of OperationContext.
- #message(component_class) ⇒ Object
- #operationId(value) ⇒ Object
Constructor Details
#initialize(kind, summary = nil) ⇒ OperationContext
Returns a new instance of OperationContext.
9 10 11 12 13 14 15 16 17 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 9 def initialize(kind, summary = nil) unless KINDS.include?(kind) raise ArgumentError, "operation kind must be one of #{KINDS.inspect}, got #{kind.inspect}" end @kind = kind @summary = summary @messages = [] @operation_id = nil end |
Instance Attribute Details
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
6 7 8 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 6 def kind @kind end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
6 7 8 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 6 def @messages end |
#operation_id ⇒ Object
Returns the value of attribute operation_id.
7 8 9 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 7 def operation_id @operation_id end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
6 7 8 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 6 def summary @summary end |
Instance Method Details
#message(component_class) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 19 def (component_class) unless component_class.is_a?(Class) && component_class < OpenapiRuby::Components::Base raise ArgumentError, "message must be an OpenapiRuby::Components::Base subclass, got #{component_class.inspect}" end @messages << component_class component_class end |
#operationId(value) ⇒ Object
27 28 29 |
# File 'lib/asyncapi_cable/dsl/operation_context.rb', line 27 def operationId(value) @operation_id = value end |