Class: Adhearsion::CallController

Inherits:
Object
  • Object
show all
Extended by:
ActiveSupport::Autoload
Includes:
Dial, Input, Output, Record, Utility
Defined in:
lib/adhearsion/call_controller.rb,
lib/adhearsion/call_controller/dial.rb,
lib/adhearsion/call_controller/input.rb,
lib/adhearsion/call_controller/output.rb,
lib/adhearsion/call_controller/record.rb,
lib/adhearsion/call_controller/utility.rb,
lib/adhearsion/call_controller/menu_dsl.rb,
lib/adhearsion/call_controller/menu_dsl/menu.rb,
lib/adhearsion/call_controller/menu_dsl/menu_builder.rb,
lib/adhearsion/call_controller/menu_dsl/calculated_match.rb,
lib/adhearsion/call_controller/menu_dsl/match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/range_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/fixnum_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/string_match_calculator.rb,
lib/adhearsion/call_controller/menu_dsl/calculated_match_collection.rb

Direct Known Subclasses

SimonGame

Defined Under Namespace

Modules: Dial, Input, Output, Record, Utility

Constant Summary

Constant Summary

Constants included from Record

Record::RecordError

Constants included from Output

Output::PlaybackError

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Record

#record

Methods included from Output

#interruptible_play, #play, #play_audio, #play_numeric, #play_time, #say, #stream_file

Methods included from Input

#ask, #menu

Methods included from Dial

#dial

Constructor Details

- (CallController) initialize(call, metadata = nil, &block)

Create a new instance

Parameters:

  • call (Call)

    the call to operate the controller on

  • metadata (Hash) (defaults to: nil)

    generic key-value storage applicable to the controller

  • block

    to execute on the call



75
76
77
# File 'lib/adhearsion/call_controller.rb', line 75

def initialize(call,  = nil, &block)
  @call, @metadata, @block = call,  || {}, block
end

Instance Attribute Details

- (Object) call (readonly)

Returns the value of attribute call



60
61
62
# File 'lib/adhearsion/call_controller.rb', line 60

def call
  @call
end

- (Object) metadata (readonly)

Returns the value of attribute metadata



60
61
62
# File 'lib/adhearsion/call_controller.rb', line 60

def 
  @metadata
end

Class Method Details

+ (Object) exec(controller)

Execute a call controller, allowing passing control to another controller

Parameters:



43
44
45
46
47
48
49
50
# File 'lib/adhearsion/call_controller.rb', line 43

def exec(controller)
  new_controller = catch :pass_controller do
    controller.execute!
    nil
  end

  exec new_controller if new_controller
end

+ (Object) mixin(mod)

Include another module into all CallController classes



55
56
57
# File 'lib/adhearsion/call_controller.rb', line 55

def mixin(mod)
  include mod
end

Instance Method Details

- (Object) answer(*args)

Answer the call



168
169
170
171
# File 'lib/adhearsion/call_controller.rb', line 168

def answer(*args)
  block_until_resumed
  call.answer(*args)
end

- (Object) hangup(headers = nil)

Hangup the call, and execute after_call callbacks

Parameters:

  • headers (Hash) (defaults to: nil)


140
141
142
143
144
# File 'lib/adhearsion/call_controller.rb', line 140

def hangup(headers = nil)
  block_until_resumed
  hangup_response = call.hangup headers
  after_call unless hangup_response == false
end

- (Object) invoke(controller_class, metadata = nil)

Invoke another controller class within this controller, returning to this context on completion.

Parameters:

  • controller_class (Class)

    The class of controller to execute

  • metadata (Hash) (defaults to: nil)

    generic key-value storage applicable to the controller



106
107
108
109
# File 'lib/adhearsion/call_controller.rb', line 106

def invoke(controller_class,  = nil)
  controller = controller_class.new call, 
  controller.run
end

- (Object) join(target, options = {})

Join the call to another call or a mixer, and block until the call is unjoined (by hangup or otherwise).

Parameters:

  • target (Object)

    See Call#join for details

  • options (Hash) (defaults to: {})

Options Hash (options):

  • :async (Boolean)

    Return immediately, without waiting for the calls to unjoin. Defaults to false.

See Also:



212
213
214
215
216
217
218
219
220
221
222
# File 'lib/adhearsion/call_controller.rb', line 212

def join(target, options = {})
  block_until_resumed
  async = (target.is_a?(Hash) ? target : options).delete :async
  join_command = call.join target, options
  waiter = join_command.call_id || join_command.mixer_name
  if async
    call.wait_for_joined waiter
  else
    call.wait_for_unjoined waiter
  end
end

- (Object) mute(*args)

Mute the call



188
189
190
191
# File 'lib/adhearsion/call_controller.rb', line 188

def mute(*args)
  block_until_resumed
  call.mute(*args)
end

- (Object) pass(controller_class, metadata = nil)

Cease execution of this controller, and pass to another.

Parameters:

  • controller_class (Class)

    The class of controller to pass to

  • metadata (Hash) (defaults to: nil)

    generic key-value storage applicable to the controller



117
118
119
# File 'lib/adhearsion/call_controller.rb', line 117

def pass(controller_class,  = nil)
  throw :pass_controller, controller_class.new(call, )
end

- (Object) reject(*args)

Reject the call



178
179
180
181
# File 'lib/adhearsion/call_controller.rb', line 178

def reject(*args)
  block_until_resumed
  call.reject(*args)
end

- (Object) run

Invoke the block supplied when creating the controller



96
97
98
# File 'lib/adhearsion/call_controller.rb', line 96

def run
  instance_exec(&block) if block
end

- (Object) unmute(*args)

Unmute the call



198
199
200
201
# File 'lib/adhearsion/call_controller.rb', line 198

def unmute(*args)
  block_until_resumed
  call.unmute(*args)
end