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.
104 105 106 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 104 def context @context end |
#dial_plan ⇒ Object
Returns the value of attribute dial_plan.
104 105 106 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 104 def dial_plan @dial_plan end |
Class Method Details
.handle(call) ⇒ Object
99 100 101 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 99 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
129 130 131 132 133 134 135 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 129 def entry_point_for(call) if call.respond_to?(:request) && m = call.request.path.match(%r{/([^/]+)}) dial_plan.lookup(m[1].to_sym) elsif entry_point = dial_plan.lookup(call.context.to_sym) entry_point end end |
#handle(call) ⇒ Object
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/adhearsion/voip/dial_plan.rb', line 109 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 |