Module: ActionService::Invocation::InstanceMethods
- Defined in:
- lib/action_service/invocation.rb
Overview
:nodoc:
Class Method Summary collapse
Instance Method Summary collapse
- #after_invocation(name, args, result) ⇒ Object
- #before_invocation(name, args, &block) ⇒ Object
- #perform_invocation(invocation) ⇒ Object
- #perform_invocation_with_interception(invocation, &block) ⇒ Object
Class Method Details
.append_features(base) ⇒ Object
135 136 137 138 139 140 141 |
# File 'lib/action_service/invocation.rb', line 135 def self.append_features(base) super base.class_eval do alias_method :perform_invocation_without_interception, :perform_invocation alias_method :perform_invocation, :perform_invocation_with_interception end end |
Instance Method Details
#after_invocation(name, args, result) ⇒ Object
173 174 175 |
# File 'lib/action_service/invocation.rb', line 173 def after_invocation(name, args, result) call_interceptors(self.class.after_invocation_interceptors, [name, args, result]) end |
#before_invocation(name, args, &block) ⇒ Object
169 170 171 |
# File 'lib/action_service/invocation.rb', line 169 def before_invocation(name, args, &block) call_interceptors(self.class.before_invocation_interceptors, [name, args], &block) end |
#perform_invocation(invocation) ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/action_service/invocation.rb', line 150 def perform_invocation(invocation) if invocation.concrete? unless self.respond_to?(invocation.method_name) && self.class.has_export?(invocation.method_name) raise InvocationError, "no such exported method '#{invocation.method_name}'" end end params = invocation.params if invocation.concrete? || invocation.unexported_concrete? self.send(invocation.method_name, *params) else if invocation.block params = invocation.block_params + params invocation.block.call(invocation.public_method_name, *params) else self.send(invocation.method_name, *params) end end end |
#perform_invocation_with_interception(invocation, &block) ⇒ Object
143 144 145 146 147 148 |
# File 'lib/action_service/invocation.rb', line 143 def perform_invocation_with_interception(invocation, &block) return if before_invocation(invocation.method_name, invocation.params, &block) == false result = perform_invocation_without_interception(invocation) after_invocation(invocation.method_name, invocation.params, result) result end |