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.



31
32
33
# File 'lib/adhearsion/voip/dial_plan.rb', line 31

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

Instance Attribute Details

#callObject (readonly)

Returns the value of attribute call.



30
31
32
# File 'lib/adhearsion/voip/dial_plan.rb', line 30

def call
  @call
end

Class Method Details

.create(*args) ⇒ Object



25
26
27
# File 'lib/adhearsion/voip/dial_plan.rb', line 25

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

Instance Method Details

#runObject



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/adhearsion/voip/dial_plan.rb', line 45

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.



39
40
41
42
43
# File 'lib/adhearsion/voip/dial_plan.rb', line 39

def stage!
  extend_with_voip_commands!
  extend_with_call_variables!
  extend_with_dialplan_component_methods!
end