lib/adhearsion/call_controller.rb in adhearsion-3.0.0.beta1 vs lib/adhearsion/call_controller.rb in adhearsion-3.0.0.beta2

- old
+ new

@@ -16,11 +16,11 @@ include Output include Record class_attribute :callbacks - self.callbacks = {:before_call => [], :after_call => [], :on_error => []} + self.callbacks = {:before => [], :after => [], :on_error => []} self.callbacks.keys.each do |name| class_eval <<-STOP def self.#{name}(method_name = nil, &block) callback = if method_name @@ -47,10 +47,20 @@ # Include another module into all CallController classes # def mixin(mod) include mod end + + def before_call(*args, &block) + Adhearsion.deprecated :before + before(*args, &block) + end + + def after_call(*args, &block) + Adhearsion.deprecated :after + after(*args, &block) + end end # @return [Call] The call object on which the controller is executing attr_reader :call @@ -111,19 +121,19 @@ end # @private def execute!(*options) call.async.register_controller self - execute_callbacks :before_call + execute_callbacks :before run rescue Call::Hangup, Call::ExpiredError rescue SyntaxError, StandardError => e Events.trigger :exception, [e, logger] on_error e raise ensure - after_call + after logger.debug "Finished executing controller #{self.inspect}" end # # Invoke the block supplied when creating the controller @@ -187,12 +197,12 @@ end end end # @private - def after_call - @after_call ||= execute_callbacks :after_call + def after + @after ||= execute_callbacks :after end # @private def on_error(e) @error = e @@ -232,10 +242,10 @@ block_until_resumed call.answer(*args) end # - # Hangup the call, and execute after_call callbacks + # Hangup the call, and execute after callbacks # # @param [Hash] headers # def hangup(headers = nil) block_until_resumed