nexus_cqrs 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67530620fea3787829b05b73fff8cf78b8414a6adcd79332f727e77d98ae07e2
4
- data.tar.gz: cf1ee994dd29425087dec599192ad629b9a0e62910326c666dfa1b9671aa49ca
3
+ metadata.gz: a0ab24d08b1c4793fef6e3834988672a80f16ebb82d6dbda3d5541c924b8c831
4
+ data.tar.gz: ba846c3ce5ca8ca11254ad1521fe89498bed086f3fe1728bc8712343e7352962
5
5
  SHA512:
6
- metadata.gz: 8b9d852ecbe12b1158ff57823b97d614556ccca1e31d97cb7ee1ddfb9491881801bebc97818fb70f74ecabfe03932e0955ea1f50241079026c7c9af061de8de1
7
- data.tar.gz: 72141ebc08db7e350973def5ff749bf0260bba02910c4d31decea711b392e291c28c0c1c13103364505137327f68e5fe9aa5e0899a97e0baef7731f0daec4c12
6
+ metadata.gz: 94e1db49bdbe1d8a03e4341d95d88c4abd42c9c38be178ad85f813095dded808fa9a76b51b32a95d40886666d9208d2f3f74ce21936e8dda8b48b7fe34a87dee
7
+ data.tar.gz: f560cb815379e847dd6cb347346d0eefdefda8234b8aa0ae146114b85be4109af81f6436e65e699a2a51da8219e7baa0dcebd5758ced123a54e47a44c7006a46
data/README.md CHANGED
@@ -22,19 +22,10 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Generators can be used to aide in the creation of Commands and Queries:
26
26
 
27
- ## Development
27
+ rails g nexus_cqrs:command CommandName
28
+ rails g nexus_cqrs:query QueryName
28
29
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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, " do_stuff(foo)\n"
20
+ end
11
21
  end
12
22
  end
@@ -1,5 +1,5 @@
1
1
  module Commands
2
- class <%= class_name %> < BaseCommand
2
+ class <%= class_name %> < NexusCqrs::BaseCommand
3
3
 
4
4
  # Define attributes for this command
5
5
  attr_accessor :id
@@ -1,5 +1,5 @@
1
1
  module Commands
2
- class <%= class_name %>Handler < BaseCommandHandler
2
+ class <%= class_name %>Handler < NexusCqrs::BaseCommandHandler
3
3
 
4
4
  # call is where the Command is executed
5
5
  def call(command)
@@ -1,5 +1,5 @@
1
1
  module Queries
2
- class <%= class_name %> < BaseQuery
2
+ class <%= class_name %> < NexusCqrs::BaseQuery
3
3
 
4
4
  # Define attributes for this query
5
5
  attr_accessor :id
@@ -1,5 +1,5 @@
1
1
  module Queries
2
- class <%= class_name %>Handler < BaseQueryHandler
2
+ class <%= class_name %>Handler < NexusCqrs::BaseQueryHandler
3
3
 
4
4
  # call is where the Query is executed
5
5
  def call(command)
@@ -0,0 +1,4 @@
1
+ command_bus = NexusCqrs::CommandBus.new
2
+ query_bus = NexusCqrs::CommandBus.new
3
+
4
+ $CQRS_EXECUTOR = NexusCqrs::CommandExecutor.new command_bus
@@ -1,7 +1,7 @@
1
1
  module NexusCqrs
2
2
  class CommandExecutor
3
- def initialize
4
- @bus = CommandBus.new
3
+ def initialize(command_bus)
4
+ @bus = command_bus
5
5
 
6
6
  register_commands
7
7
  end
@@ -10,6 +10,10 @@ module NexusCqrs
10
10
  @bus.(command)
11
11
  end
12
12
 
13
+ def register_command klass, handler
14
+ @bus.register(klass, handler)
15
+ end
16
+
13
17
  private
14
18
  def register_commands
15
19
  # TODO, Register Commands/Queries
@@ -1,3 +1,3 @@
1
1
  module NexusCqrs
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
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.3
4
+ version: 0.0.4
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-20 00:00:00.000000000 Z
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,7 @@ 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
62
63
  - lib/nexus_cqrs.rb
63
64
  - lib/nexus_cqrs/base_command.rb
64
65
  - lib/nexus_cqrs/base_command_handler.rb