Module: NexusCqrs::Helpers

Defined in:
lib/nexus_cqrs/helpers.rb

Overview

Simple module to inject execution methods into a class. Used to execute commands and queries from controllers and/or graphql resolvers.

Instance Method Summary collapse

Instance Method Details

#command_executorNexusCqrs::CommandExecutor

Provide access to the CQRS command executor

Returns:



27
28
29
# File 'lib/nexus_cqrs/helpers.rb', line 27

def command_executor
  @command_executor ||= $COMMAND_EXECUTOR
end

#execute(command) ⇒ Object

Executes a CQRS Command

Examples:

Execute a command

execute(DeleteMod.new(mod.id))

Parameters:



11
12
13
# File 'lib/nexus_cqrs/helpers.rb', line 11

def execute(command)
  command_executor.execute(command)
end

#query(query) ⇒ Object

Executes a CQRS Query

Examples:

Execute a query

execute(GetMod.new(mod.id))

Parameters:



20
21
22
# File 'lib/nexus_cqrs/helpers.rb', line 20

def query(query)
  query_executor.execute(query)
end

#query_executorNexusCqrs::CommandExecutor

Provide access to the CQRS query executor

Returns:



34
35
36
# File 'lib/nexus_cqrs/helpers.rb', line 34

def query_executor
  @query_executor ||= $QUERY_EXECUTOR
end