nexus_cqrs 0.0.1 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +6 -15
- data/lib/generators/nexus_cqrs/command_generator.rb +10 -0
- data/lib/generators/nexus_cqrs/templates/command.rb +1 -1
- data/lib/generators/nexus_cqrs/templates/command_handler.rb +1 -1
- data/lib/generators/nexus_cqrs/templates/query.rb +1 -1
- data/lib/generators/nexus_cqrs/templates/query_handler.rb +1 -1
- data/lib/generators/nexus_cqrs/templates/register_cqrs_handlers.rb +9 -0
- data/lib/nexus_cqrs.rb +11 -0
- data/lib/nexus_cqrs/command_bus.rb +1 -1
- data/lib/nexus_cqrs/command_executor.rb +7 -2
- data/lib/nexus_cqrs/helpers.rb +2 -7
- data/lib/nexus_cqrs/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 166e19872cf44b2a581e7d3c3c744c1500bf9b6259dff4678e1b6a817d2b8b64
|
4
|
+
data.tar.gz: ebe24c347b567a40f529e0b8409fff8d1bb9410044b03d7b03e6cae896d6e8d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 519f57716334745b55e303914758549f0b2652d94c353d3bd78264f73db44f5e47a4eaa9aeb3e6bef017f49c44e0fea7745c2a671fad72972d830da52e59e0f7
|
7
|
+
data.tar.gz: 3dd5eba476cc5b87d3c0217417ab5e8323fce73f925db26fccfd79b9e02a18ff6daff5e55adec12cd9b45cb0b45849f1ba4fc01dc5cf8c82b0c86b8e6f4daa5b
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@ TODO: Delete this and the text above, and describe your gem
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
11
11
|
```ruby
|
12
|
-
gem '
|
12
|
+
gem 'nexus_cqrs'
|
13
13
|
```
|
14
14
|
|
15
15
|
And then execute:
|
@@ -18,23 +18,14 @@ And then execute:
|
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
$ gem install
|
21
|
+
$ gem install nexus_cqrs
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Generators can be used to aide in the creation of Commands and Queries:
|
26
26
|
|
27
|
-
|
27
|
+
rails g nexus_cqrs:command CommandName
|
28
|
+
rails g nexus_cqrs:query QueryName
|
28
29
|
|
29
|
-
|
30
|
+
Once installed, a CommandBus is required to control the flow of Commands and/or Queries:
|
30
31
|
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cqrs-core. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cqrs-core/blob/master/CODE_OF_CONDUCT.md).
|
36
|
-
|
37
|
-
|
38
|
-
## Code of Conduct
|
39
|
-
|
40
|
-
Everyone interacting in the Cqrs::Core project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cqrs-core/blob/master/CODE_OF_CONDUCT.md).
|
@@ -8,5 +8,15 @@ module NexusCqrs
|
|
8
8
|
template "command.rb", "app/domain/commands/#{file_name}.rb"
|
9
9
|
template "command_handler.rb", "app/domain/commands/#{file_name}_handler.rb"
|
10
10
|
end
|
11
|
+
|
12
|
+
def register_command
|
13
|
+
handler_config = "config/initializers/register_cqrs_handlers.rb"
|
14
|
+
|
15
|
+
unless File.exist?('config/initializers/register_cqrs_handlers.rb')
|
16
|
+
template "register_cqrs_handlers.rb", handler_config
|
17
|
+
end
|
18
|
+
|
19
|
+
inject_into_file handler_config, "$QUERY_EXECUTOR.register_command(Queries::Stripe::GetCustomerById, Queries::Stripe::GetCustomerByIdHandler)", after: "# Register Commands"
|
20
|
+
end
|
11
21
|
end
|
12
22
|
end
|
data/lib/nexus_cqrs.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'nexus_cqrs/base_command'
|
2
|
+
require 'nexus_cqrs/base_command_handler'
|
3
|
+
require 'nexus_cqrs/base_query'
|
4
|
+
require 'nexus_cqrs/base_query_handler'
|
5
|
+
require 'nexus_cqrs/command_bus'
|
6
|
+
require 'nexus_cqrs/command_executor'
|
7
|
+
require 'nexus_cqrs/helpers'
|
8
|
+
|
9
|
+
module NexusCqrs
|
10
|
+
class Error < StandardError; end
|
11
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module NexusCqrs
|
2
2
|
class CommandExecutor
|
3
|
-
def initialize
|
4
|
-
@bus =
|
3
|
+
def initialize(command_bus)
|
4
|
+
@bus = command_bus
|
5
5
|
|
6
6
|
register_commands
|
7
7
|
end
|
@@ -10,6 +10,11 @@ module NexusCqrs
|
|
10
10
|
@bus.(command)
|
11
11
|
end
|
12
12
|
|
13
|
+
def register_command klass, handler
|
14
|
+
Rails.logger.debug "Registered #{klass} to #{handler}"
|
15
|
+
@bus.register(klass, handler)
|
16
|
+
end
|
17
|
+
|
13
18
|
private
|
14
19
|
def register_commands
|
15
20
|
# TODO, Register Commands/Queries
|
data/lib/nexus_cqrs/helpers.rb
CHANGED
@@ -2,17 +2,12 @@ module NexusCqrs
|
|
2
2
|
module Helpers
|
3
3
|
# Executes a CQRS Command
|
4
4
|
def execute(command)
|
5
|
-
|
5
|
+
$COMMAND_EXECUTOR.execute(command)
|
6
6
|
end
|
7
7
|
|
8
8
|
# Executes a CQRS Query
|
9
9
|
def query(query)
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
# Provide access to the CQRS executor
|
14
|
-
def command_executor
|
15
|
-
@command_executor ||= NexusCqrs::CommandExecutor.new
|
10
|
+
$QUERY_EXECUTOR.execute(query)
|
16
11
|
end
|
17
12
|
end
|
18
13
|
end
|
data/lib/nexus_cqrs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Lovett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -59,6 +59,8 @@ files:
|
|
59
59
|
- lib/generators/nexus_cqrs/templates/command_handler.rb
|
60
60
|
- lib/generators/nexus_cqrs/templates/query.rb
|
61
61
|
- lib/generators/nexus_cqrs/templates/query_handler.rb
|
62
|
+
- lib/generators/nexus_cqrs/templates/register_cqrs_handlers.rb
|
63
|
+
- lib/nexus_cqrs.rb
|
62
64
|
- lib/nexus_cqrs/base_command.rb
|
63
65
|
- lib/nexus_cqrs/base_command_handler.rb
|
64
66
|
- lib/nexus_cqrs/base_query.rb
|