class Adhearsion::Router::Route
Attributes
controller_metadata[RW]
guards[R]
name[R]
target[R]
Public Class Methods
new(name, target = nil, *guards, &block)
click to toggle source
# File lib/adhearsion/router/route.rb, line 13 def initialize(name, target = nil, *guards, &block) @name = name if block @target, @guards = block, ([target] + guards) else @target, @guards = target, guards end @guards.compact! @controller_metadata = nil end
Public Instance Methods
accepting?()
click to toggle source
# File lib/adhearsion/router/route.rb, line 65 def accepting? true end
dispatch(call, callback = nil)
click to toggle source
# File lib/adhearsion/router/route.rb, line 28 def dispatch(call, callback = nil) Adhearsion::Events.trigger_immediately :call_routed, call: call, route: self call_id = call.id # Grab this to use later incase the actor is dead controller = if target.respond_to?(:call) CallController.new call, controller_metadata, &target else target.new call, controller_metadata end call.accept if accepting? call.execute_controller controller, lambda { |call_actor| begin if call_actor.alive? && call_actor.active? if call_actor.auto_hangup logger.info "Call #{call_id} routing completed. Hanging up now." call_actor.hangup else logger.info "Call #{call_id} routing completed. Keeping the call alive at controller/router request." end else logger.info "Call #{call_id} routing completed. Call was already hung up." end rescue Call::Hangup, Call::ExpiredError end callback.call if callback } rescue Call::Hangup, Call::ExpiredError logger.info "Call routing could not be completed because call was unavailable." end
evented?()
click to toggle source
# File lib/adhearsion/router/route.rb, line 61 def evented? false end
inspect()
click to toggle source
# File lib/adhearsion/router/route.rb, line 73 def inspect "#<#{self.class}:#{object_id} name=#{name} target=#{target} guards=#{guards}>" end
Also aliased as: to_s
match?(call)
click to toggle source
# File lib/adhearsion/router/route.rb, line 24 def match?(call) !guarded? guards, call end
openended?()
click to toggle source
# File lib/adhearsion/router/route.rb, line 69 def openended? false end