Module: MimeActor::Stage
Overview
# MimeActor Stage
Stage provides helper methods for actor lookup and invocation.
Constant Summary
Constants included from Callbacks
Instance Method Summary collapse
-
#cue_actor(actor, *args, action:, format:) ⇒ Object
Calls the ‘actor` and passing arguments to it.
Methods included from Rescue
Methods included from Callbacks
Instance Method Details
#cue_actor(actor, *args, action:, format:) ⇒ Object
Calls the ‘actor` and passing arguments to it. If a block is given, the result from the `actor` method will be yieled to the block.
NOTE: method call on actor if it is String or Symbol. Proc#call if actor is Proc
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/mime_actor/stage.rb', line 37 def cue_actor(actor, *args, action:, format:) dispatcher = MimeActor::Dispatcher.build(actor, *args) raise TypeError, "invalid actor, got: #{actor.inspect}" unless dispatcher self.class.validate!(:format, format) run_act_callbacks(action: action, format: format) do result = dispatcher.call(self) block_given? ? yield(result) : result end rescue MimeActor::ActorNotFound => e logger.error { "actor error, cause: #{e.inspect}" } unless raise_on_actor_error raise e if raise_on_actor_error rescue StandardError => e rescued = rescue_actor(e, action: action, format: format) rescued || raise end |