Class: PresenceChannel::State

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Serialization
Defined in:
lib/presence_channel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message_bus_last_id:, user_ids: nil, count: nil) ⇒ State

Returns a new instance of State.



22
23
24
25
26
27
# File 'lib/presence_channel.rb', line 22

def initialize(message_bus_last_id:, user_ids: nil, count: nil)
  raise "user_ids or count required" if user_ids.nil? && count.nil?
  @message_bus_last_id = message_bus_last_id
  @user_ids = user_ids
  @count = count || user_ids.count
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



20
21
22
# File 'lib/presence_channel.rb', line 20

def count
  @count
end

#message_bus_last_idObject (readonly)

Returns the value of attribute message_bus_last_id.



18
19
20
# File 'lib/presence_channel.rb', line 18

def message_bus_last_id
  @message_bus_last_id
end

#user_idsObject (readonly)

Returns the value of attribute user_ids.



19
20
21
# File 'lib/presence_channel.rb', line 19

def user_ids
  @user_ids
end

Instance Method Details

#usersObject



29
30
31
32
# File 'lib/presence_channel.rb', line 29

def users
  return nil if user_ids.nil?
  User.where(id: user_ids)
end