Class: AsyncapiCable::Dsl::ChannelContext

Inherits:
Object
  • Object
show all
Defined in:
lib/asyncapi_cable/dsl/channel_context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_classObject (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

#operationsObject (readonly)

Returns the value of attribute operations.



4
5
6
# File 'lib/asyncapi_cable/dsl/channel_context.rb', line 4

def operations
  @operations
end

#parametersObject (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_nameObject (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_templateObject (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