Class: CEML::CastingPool

Inherits:
Struct
  • Object
show all
Defined in:
lib/ceml/models/casting_pool.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#room_idsObject

Returns the value of attribute room_ids

Returns:

  • (Object)

    the current value of room_ids



2
3
4
# File 'lib/ceml/models/casting_pool.rb', line 2

def room_ids
  @room_ids
end

Class Method Details

.destroy_everywhere(bundle_id, player_id) ⇒ Object



3
4
5
# File 'lib/ceml/models/casting_pool.rb', line 3

def self.destroy_everywhere(bundle_id, player_id)
  CastingTokens.destroy([player_id])
end

Instance Method Details

#claim(player_ids) ⇒ Object



17
18
19
20
# File 'lib/ceml/models/casting_pool.rb', line 17

def claim(player_ids)
  tokens = @tokens_by_player_id.values_at(*player_ids)
  CastingTokens.collect(tokens)
end

#hot_playersObject



13
14
15
# File 'lib/ceml/models/casting_pool.rb', line 13

def hot_players
  player_ids.map{ |id| Player.new(id).data.value }
end

#player_idsObject



7
8
9
10
11
# File 'lib/ceml/models/casting_pool.rb', line 7

def player_ids
  tokens = CastingTokens.all_tokens(room_ids)
  @tokens_by_player_id = tokens.inject({}){ |m,o| m[o]=o; m }
  @tokens_by_player_id.keys
end

#post(bundle_id, player_id) ⇒ Object



22
23
24
# File 'lib/ceml/models/casting_pool.rb', line 22

def post(bundle_id, player_id)
  CastingTokens.post(bundle_id, player_id, room_ids)
end