cqrs-core 0.1.2 → 0.1.7

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: a4cef44d18e6e3e10636a328129f4d4fd4a1deb4fed9d447b4ab01f8b677390e
4
- data.tar.gz: a8d9ed00ccf562f69e90860a644abe006d48a8b85f4a3fdc3ed7acf4d918df47
3
+ metadata.gz: c48df792d3739e54a1cd70358f7af03ab2a9d5f1ff20759e0b61cdee8a6bf116
4
+ data.tar.gz: e1c9f5d8666b09118fdccc6e7c08fcc687bd411c157def85df0e750e0b52ff9f
5
5
  SHA512:
6
- metadata.gz: f9ac7cb9e2ae387c87c33c36dceffa6bd8db194bb7dfd82faad095abbca471806b3014e8a2e843012423a1600451a8e1a6fe73840dbaa4c2fede38e8215981ea
7
- data.tar.gz: ab2bbe2503382152b3b4ed8d5badf67c1a79af1c5f598631a937aaae46e9b06209aeda091440238ae5769d3a285b2e1dbbe8b37c51bc1a39e00c5feea87b4d02
6
+ metadata.gz: 18943718a56983d5ab8da3a1839234cf607d02a3da6f92aeb98da55a477d8b063b3eb181f0dedb48300d25bbe712cbdb2f70615ff662d766023f467b030202b2
7
+ data.tar.gz: 891c28156a57eb0b59bba99cf4b7550858067bc245baf5ed5380317fdfd245599e515daaf9e7c842a6fa85425694de779362c652b14da69c4ffebc962fb16a85
@@ -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_dependency('cqrs-generators', '~> 0.0')
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::Core
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.2"
3
+ VERSION = "0.1.7"
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.2
4
+ version: 0.1.7
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.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.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: {}