Module: PusherFake::Channel
- Defined in:
- lib/pusher-fake/channel.rb,
lib/pusher-fake/channel/public.rb,
lib/pusher-fake/channel/private.rb,
lib/pusher-fake/channel/presence.rb
Defined Under Namespace
Classes: Presence, Private, Public
Constant Summary collapse
- PRIVATE_CHANNEL_MATCHER =
Name matcher for private channels.
/\Aprivate-/.freeze
- PRESENCE_CHANNEL_MATCHER =
Name matcher for presence channels.
/\Apresence-/.freeze
Class Attribute Summary collapse
-
.channels ⇒ Hash
Cache of existing channels.
Class Method Summary collapse
-
.factory(name) ⇒ Public|Private
Create a channel, determining the type by the name.
-
.remove(connection) ⇒ Object
Remove a connection from all channels.
-
.reset ⇒ Object
Reset the channel cache.
Class Attribute Details
.channels ⇒ Hash
Returns Cache of existing channels.
15 16 17 |
# File 'lib/pusher-fake/channel.rb', line 15 def channels @channels end |
Class Method Details
.factory(name) ⇒ Public|Private
Create a channel, determining the type by the name.
21 22 23 24 |
# File 'lib/pusher-fake/channel.rb', line 21 def factory(name) self.channels ||= {} self.channels[name] ||= class_for(name).new(name) end |
.remove(connection) ⇒ Object
Remove a connection from all channels.
Also deletes the channel if it is empty.
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/pusher-fake/channel.rb', line 31 def remove(connection) return if channels.nil? channels.each do |name, channel| channel.remove(connection) if channels[name].connections.empty? channels.delete(name) end end end |
.reset ⇒ Object
Reset the channel cache.
44 45 46 |
# File 'lib/pusher-fake/channel.rb', line 44 def reset self.channels = {} end |