1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Return subscription object(s) when updating the collection

This commit is contained in:
Javan Makhmali 2016-03-04 10:32:43 -05:00
parent 7fe67bb67a
commit 1d5f80c758

View file

@ -16,8 +16,6 @@ class ActionCable.Subscriptions
subscription = new ActionCable.Subscription @consumer, params, mixin
@add(subscription)
subscription
# Private
add: (subscription) ->
@ -25,20 +23,23 @@ class ActionCable.Subscriptions
@consumer.ensureActiveConnection()
@notify(subscription, "initialized")
@sendCommand(subscription, "subscribe")
subscription
remove: (subscription) ->
@forget(subscription)
unless @findAll(subscription.identifier).length
@sendCommand(subscription, "unsubscribe")
subscription
reject: (identifier) ->
for subscription in @findAll(identifier)
@forget(subscription)
@notify(subscription, "rejected")
subscription
forget: (subscription) ->
@subscriptions = (s for s in @subscriptions when s isnt subscription)
subscription
findAll: (identifier) ->
s for s in @subscriptions when s.identifier is identifier