Class: Adhearsion::Calls

Inherits:
Hash
  • Object
show all
Includes:
Celluloid
Defined in:
lib/adhearsion/calls.rb

Overview

This manages the list of calls the Adhearsion service receives

Instance Method Summary collapse

Methods included from Celluloid

logger

Instance Method Details

#<<(call) ⇒ Object



11
12
13
14
15
16
# File 'lib/adhearsion/calls.rb', line 11

def <<(call)
  link call
  self[call.id] = call
  by_uri[call.uri] = call
  current_actor
end

#remove_inactive_call(call) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/adhearsion/calls.rb', line 18

def remove_inactive_call(call)
  if call_is_dead?(call)
    call_id = key call
    delete call_id if call_id

    remove_call_uri call
  elsif call.respond_to?(:id)
    delete call.id
    remove_call_uri call
  else
    call_actor = delete call
    remove_call_uri call_actor
  end
end

#with_tag(tag) ⇒ Object



33
34
35
36
37
# File 'lib/adhearsion/calls.rb', line 33

def with_tag(tag)
  values.find_all do |call|
    call.tagged_with? tag
  end
end

#with_uri(uri) ⇒ Object



39
40
41
# File 'lib/adhearsion/calls.rb', line 39

def with_uri(uri)
  by_uri[uri]
end