Class: Fie::Pools

Inherits:
ActionCable::Channel::Base
  • Object
show all
Defined in:
lib/fie/pools.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.pool_name(subject) ⇒ Object



8
9
10
# File 'lib/fie/pools.rb', line 8

def pool_name(subject)
  "pool_#{ subject }"
end

.publish(subject, object, sender_uuid: nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/fie/pools.rb', line 22

def publish(subject, object, sender_uuid: nil)
  ActionCable.server.broadcast \
    pool_name(subject),
    command: 'publish_to_pool',
    parameters: {
      subject: subject,
      object: Marshal.dump(object).force_encoding(Encoding::UTF_8),
      sender_uuid: sender_uuid
    }
end

.publish_lazy(subject, object, sender_uuid) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/fie/pools.rb', line 12

def publish_lazy(subject, object, sender_uuid)
  ActionCable.server.broadcast \
    Fie::Commander.commander_name(sender_uuid),
    command: 'publish_to_pool_lazy',
    parameters: {
      subject: subject,
      object: Marshal.dump(object).force_encoding(Encoding::UTF_8)
    }
end

Instance Method Details

#subscribedObject



3
4
5
# File 'lib/fie/pools.rb', line 3

def subscribed
  stream_from Fie::Pools.pool_name(params[:identifier])
end