Module: ActionCableNotifications::Channel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/action_cable_notifications/channel.rb,
lib/action_cable_notifications/channel_cache.rb,
lib/action_cable_notifications/channel_actions.rb
Defined Under Namespace
Instance Method Summary collapse
-
#action(data) ⇒ Object
Process actions sent from the client.
- #initialize(*args) ⇒ Object
- #subscribed ⇒ Object
- #unsubscribed ⇒ Object
Methods included from Cache
Methods included from Actions
#create, #destroy, #fetch, #update
Instance Method Details
#action(data) ⇒ Object
Process actions sent from the client
"collection": "model.model_name.collection"
"command": "fetch"
"params": {
}
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/action_cable_notifications/channel.rb', line 28 def action(data) data.deep_symbolize_keys! = self.ActionCableNotifications[data[:collection]] model = [:model] broadcasting = [:broadcasting] = model.ActionCableNotificationsOptions[broadcasting] params = { model: model, model_options: , params: data[:params] } case data[:command] when "fetch" fetch(params) when "create" create(params) when "update" update(params) when "destroy" destroy(params) end end |
#initialize(*args) ⇒ Object
54 55 56 57 |
# File 'lib/action_cable_notifications/channel.rb', line 54 def initialize(*args) super @collections = {} end |
#subscribed ⇒ Object
59 60 61 62 |
# File 'lib/action_cable_notifications/channel.rb', line 59 def subscribed # XXX Check if this is new connection or a reconection of a # previously active client end |
#unsubscribed ⇒ Object
64 65 66 |
# File 'lib/action_cable_notifications/channel.rb', line 64 def unsubscribed stop_all_streams end |