Class: Cubism::PresenceChannel
- Inherits:
-
ActionCable::Channel::Base
- Object
- ActionCable::Channel::Base
- Cubism::PresenceChannel
- Includes:
- CableReady::StreamIdentifier
- Defined in:
- app/channels/cubism/presence_channel.rb
Instance Method Summary collapse
Instance Method Details
#appear ⇒ Object
26 27 28 29 30 |
# File 'app/channels/cubism/presence_channel.rb', line 26 def appear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).add(user.id), scope) if scope rescue ActiveRecord::RecordNotFound # do nothing if the user wasn't found end |
#disappear ⇒ Object
32 33 34 35 36 |
# File 'app/channels/cubism/presence_channel.rb', line 32 def disappear resource.set_present_users_for_scope(resource.present_users_for_scope(scope).delete(user.id), scope) if scope rescue ActiveRecord::RecordNotFound # do nothing if the user wasn't found end |
#subscribed ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/channels/cubism/presence_channel.rb', line 4 def subscribed return if Cubism.skip_in_test? && Rails.env.test? if resource.present? stream_from element_id resource.cubicle_element_ids << element_id resource.excluded_user_id_for_element_id[element_id] = user.id if exclude_current_user? else reject end end |
#unsubscribed ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/channels/cubism/presence_channel.rb', line 16 def unsubscribed return if Cubism.skip_in_test? && Rails.env.test? return unless resource.present? resource.cubicle_element_ids.remove(element_id) resource.excluded_user_id_for_element_id.delete(element_id) disappear end |