cqrs-core 0.1.1 → 0.1.6

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: 52a35f30c853f93ccbd277586fa9117633b2b1dc16bdeb0df2dd388516fa1c6a
4
- data.tar.gz: 2f0fe057bda919ff07b619bb515ef628dc0542d433549e14e855328b4fdc9fd6
3
+ metadata.gz: 137060e63458ed068457d7f25bb6d589419866c33b16399d363a7a9bb0ee5029
4
+ data.tar.gz: 2a8411c509d1304d1f9242ffa89aa823ef8bd91a8354880d00ad1dbdca5ae4b5
5
5
  SHA512:
6
- metadata.gz: b057794e89ea9a04a9a6eaf04e39071346f7371cb37b27202b9ac9ac1813de379a458ed7ee86c1bca3ef54d1c72934929495e45b758578369b889fb2c4b39f0b
7
- data.tar.gz: 97d5aa067e6267ff2520197381fc2951375e10933de09bcc19fe688fadc77f140b5cfcd21395999dd44c65dcebc7fcbc5bf2d6552edb360098ededaabb510b1c
6
+ metadata.gz: ca37df9b52a0ebad59ac3010a119ce163044dbebc8011bc1b594d9ef1d07b63963e0a09807e9c680202efe15a0458a73a5760995396e9b31a7d634b070a8be58
7
+ data.tar.gz: b0d19dee22f4d3cafe9e6d4b3ec4f61790329c6b8a5e247731ad0d9828d5f6874084c7f4f06f766b3332e41d7f59570acaed0abefca3884110d733b8640995ae
@@ -18,5 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_runtime_dependency "cqrs-generators"
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rails", "~> 5"
22
23
  end
@@ -0,0 +1,5 @@
1
+ module Cqrs
2
+ class BaseCommand
3
+
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ module Cqrs
2
+ class BaseCommandHandler
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Cqrs
2
+ class BaseQuery
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Cqrs
2
+ class BaseQueryHandler
3
+ end
4
+ end
@@ -0,0 +1,27 @@
1
+ require 'thread_safe'
2
+
3
+ module Cqrs
4
+ class CommandBus
5
+ UnregisteredHandler = Class.new(StandardError)
6
+ MultipleHandlers = Class.new(StandardError)
7
+
8
+ def initialize
9
+ @handlers =
10
+ ThreadSafe::Cache.new
11
+ end
12
+
13
+ def register(klass, handler)
14
+ raise MultipleHandlers.new("Multiple handlers not allowed for #{klass}") if handlers[klass]
15
+ handlers[klass] = handler
16
+ end
17
+
18
+ def call(command)
19
+ handlers
20
+ .fetch(command.class) { raise UnregisteredHandler.new("Missing handler for #{command.class}") }
21
+ .(command)
22
+ end
23
+
24
+ private
25
+ attr_reader :handlers
26
+ end
27
+ end
@@ -0,0 +1,18 @@
1
+ module Cqrs
2
+ class CommandExecutor
3
+ def initialize
4
+ @bus = CommandBus.new
5
+
6
+ register_commands
7
+ end
8
+
9
+ def execute(command)
10
+ @bus.(command)
11
+ end
12
+
13
+ private
14
+ def register_commands
15
+ # TODO, Register Commands/Queries
16
+ end
17
+ end
18
+ end
@@ -1,5 +1,5 @@
1
1
  module Cqrs
2
2
  module Core
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -0,0 +1,18 @@
1
+ module Cqrs
2
+ module Helpers
3
+ # Executes a CQRS Command
4
+ def execute(command)
5
+ command_executor.execute(command)
6
+ end
7
+
8
+ # Executes a CQRS Query
9
+ def query(query)
10
+ command_executor.execute(query)
11
+ end
12
+
13
+ # Provide access to the CQRS executor
14
+ def command_executor
15
+ @command_executor ||= NexusCqrs::CommandExecutor.new
16
+ end
17
+ end
18
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cqrs-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - dean
@@ -11,19 +11,33 @@ cert_chain: []
11
11
  date: 2020-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: cqrs-generators
14
+ name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
19
+ version: '1.3'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '5'
27
41
  description:
28
42
  email:
29
43
  - dean.lovett@nexusmods.com
@@ -39,8 +53,15 @@ files:
39
53
  - bin/console
40
54
  - bin/setup
41
55
  - cqrs-core.gemspec
56
+ - lib/cqrs/base_command.rb
57
+ - lib/cqrs/base_command_handler.rb
58
+ - lib/cqrs/base_query.rb
59
+ - lib/cqrs/base_query_handler.rb
60
+ - lib/cqrs/command_bus.rb
61
+ - lib/cqrs/command_executor.rb
42
62
  - lib/cqrs/core.rb
43
63
  - lib/cqrs/core/version.rb
64
+ - lib/cqrs/helpers.rb
44
65
  homepage:
45
66
  licenses: []
46
67
  metadata: {}