Class: Adhearsion::DialPlan::Manager
- Defined in:
- lib/adhearsion/voip/dial_plan.rb
Defined Under Namespace
Classes: NoContextError
Instance Attribute Summary collapse
-
#context ⇒ Object
Returns the value of attribute context.
-
#dial_plan ⇒ Object
Returns the value of attribute dial_plan.
Class Method Summary collapse
Instance Method Summary collapse
-
#entry_point_for(call) ⇒ Object
Find the dialplan by the context name from the call or from the first path entry in the AGI URL.
- #handle(call) ⇒ Object
-
#initialize ⇒ Manager
constructor
A new instance of Manager.
Constructor Details
Instance Attribute Details
#context ⇒ Object
Returns the value of attribute context.
85 86 87 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 85 def context @context end |
#dial_plan ⇒ Object
Returns the value of attribute dial_plan.
85 86 87 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 85 def dial_plan @dial_plan end |
Class Method Details
.handle(call) ⇒ Object
80 81 82 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 80 def handle(call) new.handle(call) end |
Instance Method Details
#entry_point_for(call) ⇒ Object
Find the dialplan by the context name from the call or from the first path entry in the AGI URL
110 111 112 113 114 115 116 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 110 def entry_point_for(call) if entry_point = dial_plan.lookup(call.context.to_sym) entry_point elsif call.respond_to?(:request) && m = call.request.path.match(%r{/([^/]+)}) dial_plan.lookup(m[1].to_sym) end end |
#handle(call) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 90 def handle(call) if call.failed_call? environment = ExecutionEnvironment.create(call, nil) call.extract_failed_reason_from environment raise FailedExtensionCallException.new(environment) end if call.hungup_call? raise HungupExtensionCallException.new(ExecutionEnvironment.new(call, nil)) end starting_entry_point = entry_point_for call raise NoContextError, "No dialplan entry point for call context '#{call.context}' -- Ignoring call!" unless starting_entry_point @context = ExecutionEnvironment.create(call, starting_entry_point) inject_context_names_into_environment @context @context.run end |