Module: CEML::CastingTokens

Defined in:
lib/ceml/models/casting_tokens.rb

Class Method Summary collapse

Class Method Details

.all_tokens(room_ids) ⇒ Object



16
17
18
19
# File 'lib/ceml/models/casting_tokens.rb', line 16

def self.all_tokens(room_ids)
  rooms = room_ids.map{ |r| WaitingRoom.new(r) }
  rooms.map{ |r| r.waiting_auditions.members }.flatten.uniq
end

.collect(tokens) ⇒ Object

this one should collect none unless all can be collected using multi/exec



46
47
48
# File 'lib/ceml/models/casting_tokens.rb', line 46

def self.collect(tokens)
  destroy(tokens)
end

.destroy(tokens) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ceml/models/casting_tokens.rb', line 27

def self.destroy(tokens)
  roomsets = tokens.map{ |id| Audition.new(id).rooms }
  rooms = roomsets.map(&:members).flatten.uniq
  # puts "Consuming ids #{ids.inspect} from rooms #{rooms.inspect}"
  # TODO: install new redis and re-enable watchlist
  # redis.watch(*roomsets.map(&:key))
  # redis.multi do
  # rooms = roomsets.first.union(roomsets[1,-1]) || []
  rooms.product(tokens).each do |r, id|
    # puts "DELETING #{id} from room #{r}"
    WaitingRoom.new(r).waiting_auditions.delete(id)
  end
  roomsets.map(&:clear)
  # end
  true
end

.destroy_all(bundle_id) ⇒ Object



21
22
23
24
25
# File 'lib/ceml/models/casting_tokens.rb', line 21

def self.destroy_all(bundle_id)
  all = WaitingRoom.new(bundle_id).waiting_auditions.members
  # puts "DESTROYING tokens: #{all.inspect}"
  destroy(all)
end

.post(bundle_id, token, room_ids) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/ceml/models/casting_tokens.rb', line 8

def self.post(bundle_id, token, room_ids)
  room_ids << bundle_id
  room_ids.each do |room_id|
    Audition.new(token).rooms << room_id
    WaitingRoom.new(room_id).waiting_auditions << token
  end
end