Class: PinkmanChannel
- Inherits:
-
ActionCable::Channel::Base
- Object
- ActionCable::Channel::Base
- PinkmanChannel
- Defined in:
- app/channels/pinkman_channel.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.broadcast(scope) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/channels/pinkman_channel.rb', line 17 def self.broadcast scope broadcasting = Pinkman::Broadcaster.new(scope: scope, model: model) if block_given? yield(broadcasting) if broadcasting.save broadcasting else raise "Pinkman: Error trying to broadcasting to #{broadcasting.room}." end else raise 'PinkmanChannel.broadcast: no block given' end end |
.model ⇒ Object
5 6 7 |
# File 'app/channels/pinkman_channel.rb', line 5 def self.model @model || self.to_s.gsub('Channel','').constantize end |
.model=(model) ⇒ Object
9 10 11 |
# File 'app/channels/pinkman_channel.rb', line 9 def self.model= model @model = model end |
.rooms ⇒ Object
13 14 15 |
# File 'app/channels/pinkman_channel.rb', line 13 def self.rooms @rooms ||= [] end |
Instance Method Details
#model ⇒ Object
31 32 33 |
# File 'app/channels/pinkman_channel.rb', line 31 def model self.class.model end |
#stream ⇒ Object
43 44 45 |
# File 'app/channels/pinkman_channel.rb', line 43 def stream Pinkman::Broadcaster.stream(self,current_allowed_scopes,params) end |
#subscribed ⇒ Object
35 36 37 |
# File 'app/channels/pinkman_channel.rb', line 35 def subscribed stream end |
#unsubscribed ⇒ Object
39 40 41 |
# File 'app/channels/pinkman_channel.rb', line 39 def unsubscribed stop_all_streams end |