Module: LiteCable::Channel::Registry

Defined in:
lib/lite_cable/channel/registry.rb

Overview

Stores channels identifiers and corresponding classes.

Defined Under Namespace

Classes: AlreadyRegisteredError, Error, UnknownChannelError

Class Method Summary collapse

Class Method Details

.add(id, channel_class) ⇒ Object



14
15
16
17
18
# File 'lib/lite_cable/channel/registry.rb', line 14

def add(id, channel_class)
  raise AlreadyRegisteredError if find(id)

  channels[id] = channel_class
end

.find(id) ⇒ Object Also known as: lookup



20
21
22
# File 'lib/lite_cable/channel/registry.rb', line 20

def find(id)
  channels[id]
end

.find!(id) ⇒ Object



26
27
28
29
30
31
# File 'lib/lite_cable/channel/registry.rb', line 26

def find!(id)
  channel_class = find(id)
  raise UnknownChannelError unless channel_class

  channel_class
end