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.



52
53
54
# File 'lib/adhearsion/voip/dial_plan.rb', line 52

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

Instance Attribute Details

#callObject (readonly)

Returns the value of attribute call.



51
52
53
# File 'lib/adhearsion/voip/dial_plan.rb', line 51

def call
  @call
end

Class Method Details

.create(*args) ⇒ Object



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

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

Instance Method Details

#runObject



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/adhearsion/voip/dial_plan.rb', line 66

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.



60
61
62
63
64
# File 'lib/adhearsion/voip/dial_plan.rb', line 60

def stage!
  extend_with_voip_commands!
  extend_with_call_variables!
  extend_with_dialplan_component_methods!
end