Class: Yes::Core::Commands::Bus
- Inherits:
-
Object
- Object
- Yes::Core::Commands::Bus
- Includes:
- OpenTelemetry::Trackable
- Defined in:
- lib/yes/core/commands/bus.rb
Instance Method Summary collapse
-
#call(command_or_commands, origin: nil, notifier_options: {}, batch_id: nil) ⇒ void
Passees commands on to the command processor, in case origin is not provided, it will be derived from the caller.
-
#initialize(command_processor: Processor, perform_inline: Yes::Core.configuration.process_commands_inline) ⇒ Bus
constructor
A new instance of Bus.
Constructor Details
#initialize(command_processor: Processor, perform_inline: Yes::Core.configuration.process_commands_inline) ⇒ Bus
Returns a new instance of Bus.
12 13 14 15 16 17 18 |
# File 'lib/yes/core/commands/bus.rb', line 12 def initialize( command_processor: Processor, perform_inline: Yes::Core.configuration.process_commands_inline ) @command_processor = command_processor @perform_inline = perform_inline end |
Instance Method Details
#call(command_or_commands, origin: nil, notifier_options: {}, batch_id: nil) ⇒ void
This method returns an undefined value.
Passees commands on to the command processor, in case origin is not provided, it will be derived from the caller. Also decides based on config whether to perform commands inline or not
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/yes/core/commands/bus.rb', line 27 def call( command_or_commands, origin: nil, notifier_options: {}, batch_id: nil ) origin ||= Utils::CallerUtils.origin_from_caller(caller_locations(1..1).first) perform_method = perform_inline ? :perform_now : :perform_later self.class.current_span&.add_attributes({ perform_method: perform_method.to_s, origin: }.stringify_keys) command_processor.public_send( perform_method, origin, command_or_commands, , batch_id, perform_inline ) end |