Module | ActionWebService::Invocation::ClassMethods |
In: |
vendor/rails/actionwebservice/lib/action_web_service/invocation.rb
|
Invocation interceptors provide a means to execute custom code before and after method invocations on ActionWebService::Base objects.
When running in Direct dispatching mode, ActionController filters should be used for this functionality instead.
The semantics of invocation interceptors are the same as ActionController filters, and accept the same parameters and options.
A before interceptor can also cancel execution by returning false, or returning a [false, "cancel reason"] array if it wishes to supply a reason for canceling the request.
class CustomService < ActionWebService::Base before_invocation :intercept_add, :only => [:add] def add(a, b) a + b end private def intercept_add return [false, "permission denied"] # cancel it end end
Options:
Appends the given interceptors to be called after method invocation.
# File vendor/rails/actionwebservice/lib/action_web_service/invocation.rb, line 65 65: def append_after_invocation(*interceptors, &block) 66: conditions = extract_conditions!(interceptors) 67: interceptors << block if block_given? 68: add_interception_conditions(interceptors, conditions) 69: append_interceptors_to_chain("after", interceptors) 70: end
Appends the given interceptors to be called before method invocation.
# File vendor/rails/actionwebservice/lib/action_web_service/invocation.rb, line 45 45: def append_before_invocation(*interceptors, &block) 46: conditions = extract_conditions!(interceptors) 47: interceptors << block if block_given? 48: add_interception_conditions(interceptors, conditions) 49: append_interceptors_to_chain("before", interceptors) 50: end
Prepends the given interceptors to be called after method invocation.
# File vendor/rails/actionwebservice/lib/action_web_service/invocation.rb, line 74 74: def prepend_after_invocation(*interceptors, &block) 75: conditions = extract_conditions!(interceptors) 76: interceptors << block if block_given? 77: add_interception_conditions(interceptors, conditions) 78: prepend_interceptors_to_chain("after", interceptors) 79: end
Prepends the given interceptors to be called before method invocation.
# File vendor/rails/actionwebservice/lib/action_web_service/invocation.rb, line 54 54: def prepend_before_invocation(*interceptors, &block) 55: conditions = extract_conditions!(interceptors) 56: interceptors << block if block_given? 57: add_interception_conditions(interceptors, conditions) 58: prepend_interceptors_to_chain("before", interceptors) 59: end