lib/adhearsion/router/route.rb in adhearsion-2.1.3 vs lib/adhearsion/router/route.rb in adhearsion-2.2.0
- old
+ new
@@ -22,14 +22,16 @@
def match?(call)
!guarded? guards, call
end
def dispatch(call, callback = nil)
+ Adhearsion::Events.trigger_immediately :call_routed, call: call, route: self
+
controller = if target.respond_to?(:call)
- CallController.new call, &target
+ CallController.new call, controller_metadata, &target
else
- target.new call
+ target.new call, controller_metadata
end
call.accept if accepting?
call.execute_controller controller, lambda { |call_actor|
@@ -41,9 +43,18 @@
end
rescue Call::Hangup
end
callback.call if callback
}
+ end
+
+ def controller_metadata=(metadata)
+ @controller_metadata = metadata
+ end
+
+ def controller_metadata
+ return {} unless instance_variable_defined?(:@controller_metadata)
+ @controller_metadata
end
def evented?
false
end