Class: AsyncapiCable::Dsl::ChannelContext
- Inherits:
-
Object
- Object
- AsyncapiCable::Dsl::ChannelContext
- Defined in:
- lib/asyncapi_cable/dsl/channel_context.rb
Instance Attribute Summary collapse
-
#channel_class ⇒ Object
readonly
Returns the value of attribute channel_class.
-
#operations ⇒ Object
readonly
Returns the value of attribute operations.
-
#parameters ⇒ Object
readonly
Returns the value of attribute parameters.
-
#schema_name ⇒ Object
readonly
Returns the value of attribute schema_name.
-
#stream_template ⇒ Object
readonly
Returns the value of attribute stream_template.
Instance Method Summary collapse
- #broadcast(summary = nil, &block) ⇒ Object
-
#initialize(stream_template, channel_class: nil, schema_name: nil) ⇒ ChannelContext
constructor
A new instance of ChannelContext.
-
#parameter(name, schema: nil, description: nil, client_supplied: true) ⇒ Object
client_supplied: falsemarks an address parameter the server derives (e.g. from the session) rather than one the client passes at subscribe time — the generated client omits it from the channel's params. - #publish(summary = nil, &block) ⇒ Object
- #subscribe(summary = nil, &block) ⇒ Object
Constructor Details
#initialize(stream_template, channel_class: nil, schema_name: nil) ⇒ ChannelContext
Returns a new instance of ChannelContext.
6 7 8 9 10 11 12 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 6 def initialize(stream_template, channel_class: nil, schema_name: nil) @stream_template = stream_template @channel_class = channel_class @schema_name = schema_name @parameters = [] @operations = [] end |
Instance Attribute Details
#channel_class ⇒ Object (readonly)
Returns the value of attribute channel_class.
4 5 6 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4 def channel_class @channel_class end |
#operations ⇒ Object (readonly)
Returns the value of attribute operations.
4 5 6 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4 def operations @operations end |
#parameters ⇒ Object (readonly)
Returns the value of attribute parameters.
4 5 6 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4 def parameters @parameters end |
#schema_name ⇒ Object (readonly)
Returns the value of attribute schema_name.
4 5 6 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4 def schema_name @schema_name end |
#stream_template ⇒ Object (readonly)
Returns the value of attribute stream_template.
4 5 6 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4 def stream_template @stream_template end |
Instance Method Details
#broadcast(summary = nil, &block) ⇒ Object
30 31 32 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 30 def broadcast(summary = nil, &block) add_operation(:broadcast, summary, &block) end |
#parameter(name, schema: nil, description: nil, client_supplied: true) ⇒ Object
client_supplied: false marks an address parameter the server derives
(e.g. from the session) rather than one the client passes at subscribe
time — the generated client omits it from the channel's params.
17 18 19 20 21 22 23 24 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 17 def parameter(name, schema: nil, description: nil, client_supplied: true) @parameters << { name: name.to_s, schema: schema, description: description, client_supplied: client_supplied }.compact end |
#publish(summary = nil, &block) ⇒ Object
34 35 36 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 34 def publish(summary = nil, &block) add_operation(:publish, summary, &block) end |
#subscribe(summary = nil, &block) ⇒ Object
26 27 28 |
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 26 def subscribe(summary = nil, &block) add_operation(:subscribe, summary, &block) end |