nexus_cqrs 0.0.13 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +24 -1
- data/.rspec +1 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +6 -21
- data/README.md +31 -1
- data/lib/generators/nexus_cqrs/USAGE +1 -1
- data/lib/generators/nexus_cqrs/command_generator.rb +6 -6
- data/lib/generators/nexus_cqrs/query_generator.rb +6 -6
- data/lib/generators/nexus_cqrs/templates/command_handler.rb +19 -2
- data/lib/generators/nexus_cqrs/templates/query_handler.rb +3 -2
- data/lib/generators/nexus_cqrs/templates/register_cqrs_handlers.rb +23 -6
- data/lib/nexus_cqrs/base_command.rb +2 -1
- data/lib/nexus_cqrs/base_command_handler.rb +1 -0
- data/lib/nexus_cqrs/base_message.rb +29 -0
- data/lib/nexus_cqrs/base_middleware.rb +12 -0
- data/lib/nexus_cqrs/base_query.rb +2 -1
- data/lib/nexus_cqrs/base_query_handler.rb +2 -1
- data/lib/nexus_cqrs/command_bus.rb +19 -9
- data/lib/nexus_cqrs/command_executor.rb +52 -6
- data/lib/nexus_cqrs/helpers.rb +1 -0
- data/lib/nexus_cqrs/version.rb +2 -1
- data/lib/nexus_cqrs.rb +3 -0
- data/nexus_cqrs.gemspec +3 -0
- metadata +49 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c4e6e4a145007fe8658503e9745e3be716436749d9bea2c714bca1d47b1ea4ab
|
|
4
|
+
data.tar.gz: aedbcb7c36185faf7d546e3ea5c268cba6642d0880a0a2c2cdf612e761f5096c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 83c240bd9f056d0d82e5437f52c45527be6092e83f6356c765bfa127153d8d5c5c660437598707fb470879606ede7c9fc1a28f11e42355401b177c29b37e7c45
|
|
7
|
+
data.tar.gz: 0dab29f1d52e3f4110cfb948ffbe425c342f682c01f1945ceced2385aa022201e84c7025b1cc7eb633110029efdf4e7b5e0366baf2b7466183a164a040df5ff3
|
data/.gitlab-ci.yml
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
image: "ruby:2.7"
|
|
2
2
|
|
|
3
|
+
stages:
|
|
4
|
+
- release
|
|
5
|
+
- test
|
|
6
|
+
|
|
3
7
|
before_script:
|
|
4
8
|
- sudo apt-get update -qq && sudo apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
|
|
5
9
|
- ruby -v
|
|
@@ -13,4 +17,23 @@ rspec:
|
|
|
13
17
|
|
|
14
18
|
rubocop:
|
|
15
19
|
script:
|
|
16
|
-
- bundle exec rubocop
|
|
20
|
+
- bundle exec rubocop
|
|
21
|
+
|
|
22
|
+
release:
|
|
23
|
+
stage: release
|
|
24
|
+
rules:
|
|
25
|
+
- if: '$CI_COMMIT_TAG'
|
|
26
|
+
script:
|
|
27
|
+
- mkdir -p ~/.gem
|
|
28
|
+
- cp $RUBYGEMS_CREDENTIALS ~/.gem/credentials
|
|
29
|
+
- chmod 0600 ~/.gem/credentials
|
|
30
|
+
- gem update --system
|
|
31
|
+
- ruby --version
|
|
32
|
+
- gem env version
|
|
33
|
+
- sed -i "s/0.1.0/$CI_COMMIT_TAG/g" lib/nexus_cqrs/version.rb
|
|
34
|
+
- gem build nexus_cqrs.gemspec
|
|
35
|
+
- gem push nexus_cqrs*.gem
|
|
36
|
+
artifacts:
|
|
37
|
+
paths:
|
|
38
|
+
- nexus_cqrs*.gem
|
|
39
|
+
expire_in: 30 days
|
data/.rspec
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
--require spec_helper
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
nexus_cqrs (0.0
|
|
4
|
+
nexus_cqrs (0.3.0)
|
|
5
|
+
generator_spec
|
|
6
|
+
ibsciss-middleware
|
|
7
|
+
thread_safe
|
|
5
8
|
|
|
6
9
|
GEM
|
|
7
10
|
remote: https://rubygems.org/
|
|
@@ -36,17 +39,13 @@ GEM
|
|
|
36
39
|
railties (>= 3.0.0)
|
|
37
40
|
i18n (1.8.5)
|
|
38
41
|
concurrent-ruby (~> 1.0)
|
|
42
|
+
ibsciss-middleware (0.4.2)
|
|
39
43
|
loofah (2.6.0)
|
|
40
44
|
crass (~> 1.0.2)
|
|
41
45
|
nokogiri (>= 1.5.9)
|
|
42
46
|
method_source (1.0.0)
|
|
43
47
|
mini_portile2 (2.4.0)
|
|
44
48
|
minitest (5.14.1)
|
|
45
|
-
multi_json (1.15.0)
|
|
46
|
-
net-scp (3.0.0)
|
|
47
|
-
net-ssh (>= 2.6.5, < 7.0.0)
|
|
48
|
-
net-ssh (6.1.0)
|
|
49
|
-
net-telnet (0.1.1)
|
|
50
49
|
nokogiri (1.10.10)
|
|
51
50
|
mini_portile2 (~> 2.4.0)
|
|
52
51
|
parallel (1.19.2)
|
|
@@ -79,9 +78,6 @@ GEM
|
|
|
79
78
|
rspec-expectations (3.9.2)
|
|
80
79
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
81
80
|
rspec-support (~> 3.9.0)
|
|
82
|
-
rspec-its (1.3.0)
|
|
83
|
-
rspec-core (>= 3.0.0)
|
|
84
|
-
rspec-expectations (>= 3.0.0)
|
|
85
81
|
rspec-mocks (3.9.1)
|
|
86
82
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
87
83
|
rspec-support (~> 3.9.0)
|
|
@@ -100,17 +96,6 @@ GEM
|
|
|
100
96
|
rubocop-shopify (1.0.4)
|
|
101
97
|
rubocop (>= 0.85, < 0.87)
|
|
102
98
|
ruby-progressbar (1.10.1)
|
|
103
|
-
serverspec (2.41.5)
|
|
104
|
-
multi_json
|
|
105
|
-
rspec (~> 3.0)
|
|
106
|
-
rspec-its
|
|
107
|
-
specinfra (~> 2.72)
|
|
108
|
-
sfl (2.3)
|
|
109
|
-
specinfra (2.82.19)
|
|
110
|
-
net-scp
|
|
111
|
-
net-ssh (>= 2.7)
|
|
112
|
-
net-telnet (= 0.1.1)
|
|
113
|
-
sfl
|
|
114
99
|
thor (1.0.1)
|
|
115
100
|
thread_safe (0.3.6)
|
|
116
101
|
tzinfo (1.2.7)
|
|
@@ -123,11 +108,11 @@ PLATFORMS
|
|
|
123
108
|
|
|
124
109
|
DEPENDENCIES
|
|
125
110
|
generator_spec
|
|
111
|
+
ibsciss-middleware
|
|
126
112
|
nexus_cqrs!
|
|
127
113
|
rspec
|
|
128
114
|
rubocop
|
|
129
115
|
rubocop-shopify (~> 1.0.4)
|
|
130
|
-
serverspec
|
|
131
116
|
thread_safe
|
|
132
117
|
|
|
133
118
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -29,6 +29,32 @@ Generators can be used to aide in the creation of Commands and Queries:
|
|
|
29
29
|
|
|
30
30
|
Once installed, a CommandBus is required to control the flow of Commands and/or Queries:
|
|
31
31
|
|
|
32
|
+
### Middleware
|
|
33
|
+
|
|
34
|
+
Middleware can be created by extending the base middleware:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
class MyMiddleware < NexusCqrs::BaseMiddleware
|
|
38
|
+
def call(command)
|
|
39
|
+
@next.call(command)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The above middleware will pass responsibility for execution to the next responder in the chain.
|
|
45
|
+
|
|
46
|
+
For more information on writing middleware see: https://github.com/Ibsciss/ruby-middleware
|
|
47
|
+
|
|
48
|
+
When creating a bus, middleware can be attached like so:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
middleware_stack = Middleware::Builder.new do |b|
|
|
52
|
+
b.use MyMiddleware
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
command_bus = Bus.new(middleware: middleware_stack)
|
|
56
|
+
```
|
|
57
|
+
|
|
32
58
|
## Development
|
|
33
59
|
|
|
34
60
|
To contribute to this gem, simple pull the repository, run `bundle install` and run tests:
|
|
@@ -36,4 +62,8 @@ To contribute to this gem, simple pull the repository, run `bundle install` and
|
|
|
36
62
|
```shell script
|
|
37
63
|
bundle exec rspec
|
|
38
64
|
bundle exec rubocop
|
|
39
|
-
```
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Releasing
|
|
68
|
+
|
|
69
|
+
The release process is tied to the git tags. Simply creating a new tag and pushing will trigger a new release to reubygems.
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'rails/generators/base'
|
|
2
3
|
|
|
3
4
|
module NexusCqrs
|
|
4
5
|
class CommandGenerator < Rails::Generators::NamedBase
|
|
5
6
|
source_root File.expand_path('templates', __dir__)
|
|
7
|
+
class_option :permission, type: :string, default: nil
|
|
6
8
|
|
|
7
9
|
def copy_command_file
|
|
8
10
|
file_path = class_name.underscore
|
|
9
11
|
|
|
12
|
+
@permission = options['permission']
|
|
13
|
+
|
|
10
14
|
template('command.rb', "app/domain/commands/#{file_path}.rb")
|
|
11
15
|
template('command_handler.rb', "app/domain/commands/#{file_path}_handler.rb")
|
|
12
16
|
|
|
13
|
-
register_command
|
|
17
|
+
register_command
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
private
|
|
17
21
|
|
|
18
|
-
def register_command
|
|
22
|
+
def register_command
|
|
19
23
|
handler_config = 'config/initializers/register_cqrs_handlers.rb'
|
|
20
24
|
|
|
21
25
|
unless File.exist?('config/initializers/register_cqrs_handlers.rb')
|
|
22
26
|
template('register_cqrs_handlers.rb', handler_config)
|
|
23
27
|
end
|
|
24
|
-
|
|
25
|
-
code_to_inject = "$COMMAND_EXECUTOR.register_command(#{full_name}, #{full_name}Handler.new)\n"
|
|
26
|
-
|
|
27
|
-
inject_into_file(handler_config, code_to_inject, after: "# Register Commands\n")
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'rails/generators/base'
|
|
2
3
|
|
|
3
4
|
module NexusCqrs
|
|
4
5
|
class QueryGenerator < Rails::Generators::NamedBase
|
|
5
6
|
source_root File.expand_path('templates', __dir__)
|
|
7
|
+
class_option :permission, type: :string, default: nil
|
|
6
8
|
|
|
7
9
|
def copy_query_file
|
|
8
10
|
file_path = class_name.underscore
|
|
9
11
|
|
|
12
|
+
@permission = options['permission']
|
|
13
|
+
|
|
10
14
|
template('query.rb', "app/domain/queries/#{file_path}.rb")
|
|
11
15
|
template('query_handler.rb', "app/domain/queries/#{file_path}_handler.rb")
|
|
12
16
|
|
|
13
|
-
register_query
|
|
17
|
+
register_query
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
private
|
|
17
21
|
|
|
18
|
-
def register_query
|
|
22
|
+
def register_query
|
|
19
23
|
handler_config = 'config/initializers/register_cqrs_handlers.rb'
|
|
20
24
|
|
|
21
25
|
unless File.exist?('config/initializers/register_cqrs_handlers.rb')
|
|
22
26
|
template('register_cqrs_handlers.rb', handler_config)
|
|
23
27
|
end
|
|
24
|
-
|
|
25
|
-
code_to_inject = "$QUERY_EXECUTOR.register_command(#{full_name}, #{full_name}Handler.new)\n"
|
|
26
|
-
|
|
27
|
-
inject_into_file(handler_config, code_to_inject, after: "# Register Queries\n")
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
end
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module Commands
|
|
2
|
-
|
|
3
|
+
# Command handler
|
|
4
|
+
class <%= class_name %>Handler < BaseCommandHandler
|
|
5
|
+
<% if @permission %>include NexusCqrs::Helpers<% end %>
|
|
3
6
|
|
|
4
|
-
#
|
|
7
|
+
# @param [<%= class_name %>] command
|
|
5
8
|
def call(command)
|
|
9
|
+
<% if @permission %>authorize(command, Model)<% end %>
|
|
6
10
|
|
|
11
|
+
domain_event(command)
|
|
7
12
|
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def domain_event(command)
|
|
17
|
+
NexusDomainEvents::Event.new(
|
|
18
|
+
message_name: :ENTITY_WAS_ACTIONED,
|
|
19
|
+
actor: command.metadata[:current_user].member_id,
|
|
20
|
+
payload: {
|
|
21
|
+
object_id: command.id,
|
|
22
|
+
}
|
|
23
|
+
)
|
|
24
|
+
end
|
|
8
25
|
end
|
|
9
26
|
end
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
module Queries
|
|
2
2
|
class <%= class_name %>Handler < NexusCqrs::BaseQueryHandler
|
|
3
|
+
<% if @permission %>include NexusCqrs::Helpers<% end %>
|
|
3
4
|
|
|
4
|
-
#
|
|
5
|
+
# @param [<%= class_name %>] command
|
|
5
6
|
def call(command)
|
|
6
|
-
|
|
7
|
+
<% if @permission %>authorize(command, Model)<% end %>
|
|
7
8
|
end
|
|
8
9
|
end
|
|
9
10
|
end
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
Rails.configuration.to_prepare do
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
middleware_stack = Middleware::Builder.new do |b|
|
|
5
|
+
b.use(NexusCqrsAuth::AuthMiddleware)
|
|
6
|
+
end
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
command_bus = NexusCqrs::CommandBus.new(middleware: middleware_stack)
|
|
9
|
+
query_bus = NexusCqrs::CommandBus.new(middleware: middleware_stack)
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
$COMMAND_EXECUTOR = NexusCqrs::CommandExecutor.new(command_bus)
|
|
12
|
+
$QUERY_EXECUTOR = NexusCqrs::CommandExecutor.new(query_bus)
|
|
13
|
+
|
|
14
|
+
# Register Commands
|
|
15
|
+
$QUERY_EXECUTOR.configure_handlers do |executor|
|
|
16
|
+
# Manually registered queries should always go above the autoregister
|
|
17
|
+
|
|
18
|
+
executor.autoregister(NexusCqrs::BaseQuery, 'app/domain/queries')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
$COMMAND_EXECUTOR.configure_handlers do |executor|
|
|
22
|
+
# Manually registered commands should always go above the autoregister
|
|
23
|
+
|
|
24
|
+
executor.autoregister(NexusCqrs::BaseCommand, 'app/domain/commands')
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module NexusCqrs
|
|
3
|
+
class BaseMessage
|
|
4
|
+
def set_metadata(key, value)
|
|
5
|
+
@metadata = {} unless @metadata
|
|
6
|
+
@metadata[key.to_sym] = value
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def metadata
|
|
10
|
+
@metadata || {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_h
|
|
14
|
+
hash = instance_variables.each_with_object({}) do |var, acc|
|
|
15
|
+
acc[var.to_s[1..-1].to_sym] = instance_variable_get(var)
|
|
16
|
+
end
|
|
17
|
+
hash[:metadata] = @metadata || {}
|
|
18
|
+
hash
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def policy_class
|
|
22
|
+
demodularised_class_name + 'Policy'
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def demodularised_class_name
|
|
26
|
+
self.class.name.split('::').last
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
require 'thread_safe'
|
|
3
|
+
require 'middleware'
|
|
2
4
|
|
|
3
5
|
module NexusCqrs
|
|
4
6
|
class CommandBus
|
|
5
7
|
UnregisteredHandler = Class.new(StandardError)
|
|
6
8
|
MultipleHandlers = Class.new(StandardError)
|
|
7
9
|
|
|
8
|
-
def initialize
|
|
9
|
-
@handlers =
|
|
10
|
-
|
|
10
|
+
def initialize(middleware: nil)
|
|
11
|
+
@handlers = ThreadSafe::Cache.new
|
|
12
|
+
@middleware = middleware || Middleware::Builder.new
|
|
11
13
|
end
|
|
12
14
|
|
|
13
15
|
def register(klass, handler)
|
|
@@ -17,19 +19,27 @@ module NexusCqrs
|
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def call(command)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
.call(command)
|
|
22
|
+
runner = Middleware::Builder.new
|
|
23
|
+
runner.use(@middleware)
|
|
24
|
+
runner.use(->(command_) { handler_for_command(command_).call(command_) })
|
|
25
|
+
runner.call(command)
|
|
25
26
|
end
|
|
26
27
|
|
|
27
28
|
def registered_handlers
|
|
28
29
|
handlers
|
|
29
30
|
end
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
def clear_handlers
|
|
33
|
+
@handlers = ThreadSafe::Cache.new
|
|
34
|
+
end
|
|
32
35
|
|
|
33
36
|
attr_reader :handlers
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
def handler_for_command(command)
|
|
41
|
+
unregistered_handler = proc { raise UnregisteredHandler, "Missing handler for #{command.class}" }
|
|
42
|
+
handlers.fetch(command.class, &unregistered_handler)
|
|
43
|
+
end
|
|
34
44
|
end
|
|
35
45
|
end
|
|
@@ -1,24 +1,70 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
1
2
|
module NexusCqrs
|
|
2
3
|
class CommandExecutor
|
|
4
|
+
# @param [NexusCqrs::CommandBus] command_bus
|
|
3
5
|
def initialize(command_bus)
|
|
4
6
|
@bus = command_bus
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def autoregister(base_class, dir = 'app/domain/commands', ignore_strings = ['.rb', 'app/domain/'])
|
|
10
|
+
|
|
11
|
+
# Iterate over the director passed and find all ruby files, removing unwanted parts of the string.
|
|
12
|
+
Dir["#{dir}/*.rb"].each do |file|
|
|
13
|
+
ignore_strings.each { |i|
|
|
14
|
+
file.slice!(i)
|
|
15
|
+
}
|
|
16
|
+
begin
|
|
17
|
+
# Constantize class name to constant to force rails to autoload this class
|
|
18
|
+
file.camelize.constantize
|
|
19
|
+
rescue NameError => e
|
|
20
|
+
puts "WARN: Tried to autoregister #{file.camelize} but class could not be found"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
ObjectSpace.each_object(Class).select { |klass| klass < base_class }.each do |c|
|
|
25
|
+
handler_name = (c.to_s + "Handler")
|
|
26
|
+
begin
|
|
27
|
+
handler = handler_name.constantize.new
|
|
28
|
+
rescue NameError => e
|
|
29
|
+
Rails.logger.error "WARN: A command/query called `#{c}` tried to autoregister `#{handler_name}` but the class was not found"
|
|
30
|
+
next
|
|
31
|
+
end
|
|
5
32
|
|
|
6
|
-
|
|
33
|
+
if handler.respond_to?(:call)
|
|
34
|
+
register_command(c, handler)
|
|
35
|
+
else
|
|
36
|
+
Rails.logger.error "WARN: A command/query called `#{c}` tried to autoregister `#{handler_name}` but the class did not have a `call` method"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
7
39
|
end
|
|
8
40
|
|
|
41
|
+
# Returns the bus used by this executor
|
|
42
|
+
#
|
|
43
|
+
# @return [NexusCqrs::CommandBus] command_bus
|
|
44
|
+
def command_bus
|
|
45
|
+
@bus
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# @param [NexusCqrs::BaseCommand] command
|
|
9
49
|
def execute(command)
|
|
10
50
|
@bus.call(command)
|
|
11
51
|
end
|
|
12
52
|
|
|
53
|
+
# @param [NexusCqrs::BaseCommandHandler] handler
|
|
13
54
|
def register_command(klass, handler)
|
|
14
|
-
|
|
15
|
-
@bus.register(klass.name, handler)
|
|
55
|
+
@bus.register(klass, handler)
|
|
16
56
|
end
|
|
17
57
|
|
|
18
|
-
|
|
58
|
+
def reregister_handlers
|
|
59
|
+
return if @register_handlers.nil?
|
|
60
|
+
|
|
61
|
+
@bus.clear_handlers
|
|
62
|
+
@register_handlers.call(self)
|
|
63
|
+
end
|
|
19
64
|
|
|
20
|
-
def
|
|
21
|
-
|
|
65
|
+
def configure_handlers(&block)
|
|
66
|
+
@register_handlers = block
|
|
67
|
+
@register_handlers.call(self)
|
|
22
68
|
end
|
|
23
69
|
end
|
|
24
70
|
end
|
data/lib/nexus_cqrs/helpers.rb
CHANGED
data/lib/nexus_cqrs/version.rb
CHANGED
data/lib/nexus_cqrs.rb
CHANGED
data/nexus_cqrs.gemspec
CHANGED
|
@@ -17,4 +17,7 @@ Gem::Specification.new do |spec|
|
|
|
17
17
|
spec.bindir = 'exe'
|
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
19
|
spec.require_paths = ['lib']
|
|
20
|
+
spec.add_dependency('generator_spec')
|
|
21
|
+
spec.add_dependency('thread_safe')
|
|
22
|
+
spec.add_dependency('ibsciss-middleware')
|
|
20
23
|
end
|
metadata
CHANGED
|
@@ -1,15 +1,57 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: nexus_cqrs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dean Lovett
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
12
|
-
dependencies:
|
|
11
|
+
date: 2021-11-11 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: generator_spec
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: thread_safe
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: ibsciss-middleware
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
13
55
|
description:
|
|
14
56
|
email:
|
|
15
57
|
- dean.lovett@nexusmods.com
|
|
@@ -19,6 +61,7 @@ extra_rdoc_files: []
|
|
|
19
61
|
files:
|
|
20
62
|
- ".gitignore"
|
|
21
63
|
- ".gitlab-ci.yml"
|
|
64
|
+
- ".rspec"
|
|
22
65
|
- ".rubocop.yml"
|
|
23
66
|
- CODE_OF_CONDUCT.md
|
|
24
67
|
- Gemfile
|
|
@@ -38,6 +81,8 @@ files:
|
|
|
38
81
|
- lib/nexus_cqrs.rb
|
|
39
82
|
- lib/nexus_cqrs/base_command.rb
|
|
40
83
|
- lib/nexus_cqrs/base_command_handler.rb
|
|
84
|
+
- lib/nexus_cqrs/base_message.rb
|
|
85
|
+
- lib/nexus_cqrs/base_middleware.rb
|
|
41
86
|
- lib/nexus_cqrs/base_query.rb
|
|
42
87
|
- lib/nexus_cqrs/base_query_handler.rb
|
|
43
88
|
- lib/nexus_cqrs/command_bus.rb
|
|
@@ -63,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
63
108
|
- !ruby/object:Gem::Version
|
|
64
109
|
version: '0'
|
|
65
110
|
requirements: []
|
|
66
|
-
rubygems_version: 3.
|
|
111
|
+
rubygems_version: 3.2.31
|
|
67
112
|
signing_key:
|
|
68
113
|
specification_version: 4
|
|
69
114
|
summary: Core package for the nexus cqrs gem
|