Class: Adhearsion::DialPlan::ExecutionEnvironment

Inherits:
Object
  • Object
show all
Defined in:
lib/adhearsion/voip/dial_plan.rb

Overview

Executable environment for a dial plan in the scope of a call. This class has all the dialplan methods mixed into it.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(call, entry_point) ⇒ ExecutionEnvironment

Returns a new instance of ExecutionEnvironment.



48
49
50
# File 'lib/adhearsion/voip/dial_plan.rb', line 48

def initialize(call, entry_point)
  @call, @entry_point = call, entry_point
end

Instance Attribute Details

#callObject (readonly)

Returns the value of attribute call.



47
48
49
# File 'lib/adhearsion/voip/dial_plan.rb', line 47

def call
  @call
end

Class Method Details

.create(*args) ⇒ Object



42
43
44
# File 'lib/adhearsion/voip/dial_plan.rb', line 42

def create(*args)
  returning(new(*args)) { |instance| instance.stage! }
end

Instance Method Details

#runObject



62
63
64
65
66
67
68
69
70
71
72
# File 'lib/adhearsion/voip/dial_plan.rb', line 62

def run
  raise "Cannot run ExecutionEnvironment without an entry point!" unless entry_point
  current_context = entry_point
  answer if AHN_CONFIG.automatically_answer_incoming_calls
  begin
    instance_eval(&current_context)
  rescue Adhearsion::VoIP::DSL::Dialplan::ControlPassingException => exception
    current_context = exception.target
    retry
  end
end

#stage!Object

Adds the methods to this ExecutionEnvironment which make it useful. e.g. dialplan-related methods, call variables, and component methods.



56
57
58
59
60
# File 'lib/adhearsion/voip/dial_plan.rb', line 56

def stage!
  extend_with_voip_commands!
  extend_with_call_variables!
  extend_with_dialplan_component_methods!
end