Module: Cubism::Presence

Extended by:
ActiveSupport::Concern
Defined in:
app/models/concerns/cubism/presence.rb

Instance Method Summary collapse

Instance Method Details

#present_users_for_element_id_and_scope(element_id, scope = "") ⇒ Object



22
23
24
25
26
27
# File 'app/models/concerns/cubism/presence.rb', line 22

def present_users_for_element_id_and_scope(element_id, scope = "")
  users = Cubism.user_class.find(present_users_for_scope(scope).to_a)
  users.reject! { |user| user.id == excluded_user_id_for_element_id[element_id].to_i }

  users
end

#present_users_for_scope(scope = "") ⇒ Object



14
15
16
# File 'app/models/concerns/cubism/presence.rb', line 14

def present_users_for_scope(scope = "")
  present_users[scope].present? ? Marshal.load(present_users[scope]) : Set.new
end

#set_present_users_for_scope(user_ids, scope = "") ⇒ Object



18
19
20
# File 'app/models/concerns/cubism/presence.rb', line 18

def set_present_users_for_scope(user_ids, scope = "")
  present_users[scope] = Marshal.dump(Set.new(user_ids))
end

#stream_presenceObject



10
11
12
# File 'app/models/concerns/cubism/presence.rb', line 10

def stream_presence
  Cubism::Broadcaster.new(resource: self).broadcast
end