active_domain 0.1.0 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74c4d087cd860f21a6a06dc4cdf92b83d548d110
4
- data.tar.gz: 6ebb39922facc4a7206de29e81988162fb90dcac
3
+ metadata.gz: c7ba08340129529699ef9c88cbfcd40cc3e12906
4
+ data.tar.gz: b6ec97c204f267ef3ae250b95998106b58dd93cd
5
5
  SHA512:
6
- metadata.gz: 5edbadc45fbabb5483243f3a6ee77b920464b68f3a8e1c24e2efff832b6b2c53e63f96b81d41db53b9a43517256c1c2067220c098d6e8fa11e88e43c4073022b
7
- data.tar.gz: 1520d8f34006d2ec112637541f029c5d7fff16072f2e6412d0190480dde1dbc0e8f9a73d3ffbe5e2a896eadfb0c1b5fcdae302a055ead1e7a79581656825a582
6
+ metadata.gz: 82d9415210f438c7b98f17a3e3f7b16438b09a499d8d323096e5e6e6433c47a75cdd9cbb3caceddb5aff10be6f065d891de2ab105904468d131981d499e1c7e4
7
+ data.tar.gz: df0cc6c2652b61237fb639edcb953cc2085740e93a1153262d1a62f54e40a5833f33e79d6db27029c1cdc8e95fd25740cd45dced8fbf2c64ba02ec8a46b76f7f
@@ -0,0 +1,5 @@
1
+ module ActiveDomain
2
+ class UniqueCommandId < ActiveRecord::Base
3
+ self.table_name = 'unique_command_ids'
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ module ActiveDomain
2
+ class UniqueCommandIdRepository
3
+ def self.new_for(command_name)
4
+ @@commands[command_name] ||= create_or_get(command_name)
5
+ create_new @@commands[command_name]
6
+ end
7
+
8
+ private
9
+ def self.initialize
10
+ end
11
+
12
+ def self.create_or_get(command_name)
13
+ UniqueCommandId.where(command: command_name).first || UniqueCommandId.create!(command: command_name, last_id: 0)
14
+ end
15
+
16
+ def self.create_new(command)
17
+ command.update! last_id: command.last_id + 1
18
+ command.last_id
19
+ end
20
+
21
+ @@commands = {}
22
+ end
23
+ end
@@ -0,0 +1,9 @@
1
+ class CreateUniqueCommandIds < ActiveRecord::Migration
2
+ def change
3
+ create_table :unique_command_ids do |t|
4
+ t.string :command
5
+ t.integer :last_id
6
+ end
7
+ add_index :unique_command_ids, :command, unique: true
8
+ end
9
+ end
data/lib/active_domain.rb CHANGED
@@ -14,4 +14,6 @@ module ActiveDomain
14
14
 
15
15
  autoload :Event, (File.expand_path '../../app/models/active_domain/event', __FILE__)
16
16
  autoload :EventRepository, (File.expand_path '../../app/models/active_domain/event_repository',__FILE__)
17
+ autoload :UniqueCommandId, (File.expand_path '../../app/models/active_domain/unique_command_id', __FILE__)
18
+ autoload :UniqueCommandIdRepository, (File.expand_path '../../app/models/active_domain/unique_command_id_repository',__FILE__)
17
19
  end
@@ -1,12 +1,9 @@
1
1
  module ActiveDomain
2
2
  module Autoload
3
- def self.app_path=(path)
4
- dirs = []
5
- dirs << "#{path}/command_processors/**/*.rb"
6
- dirs << "#{path}/validations/**/*.rb"
7
- dirs << "#{path}/projections/**/*.rb"
8
- dirs << "#{path}/models/**/*.rb"
9
- ActiveEvent::Support::Autoloader.load_from dirs
3
+ include ActiveEvent::Support::Autoload
4
+ private
5
+ def self.dir_names
6
+ %W(domain/command_processors domain/validations domain/models domain/projections)
10
7
  end
11
8
  end
12
9
  end
@@ -21,6 +21,7 @@ module ActiveDomain
21
21
  store event
22
22
  publish event
23
23
  invoke event
24
+ event.store_infos[:store_id]
24
25
  end
25
26
 
26
27
  private
@@ -9,6 +9,7 @@ module ActiveDomain
9
9
  end
10
10
 
11
11
  def run_command(command)
12
+ RELOADER.execute_if_updated
12
13
  processor, method = @@routes[command.class]
13
14
  processor_instance(processor).method(method).call(command)
14
15
  end
@@ -13,7 +13,6 @@ module ActiveDomain
13
13
  end
14
14
 
15
15
  def run
16
- ActiveEvent::ValidationsRegistry.build
17
16
  ActiveRecord::Base.establish_connection options[:domain_database]
18
17
  ActiveEvent::EventServer.start options
19
18
  drb_uri = URI::Generic.build(options[:drb_server]).to_s
@@ -1,7 +1,7 @@
1
1
  module ActiveDomain
2
2
  # Returns the version of the currently loaded ActiveDomain as a Gem::Version
3
3
  def self.version
4
- Gem::Version.new '0.1.0'
4
+ Gem::Version.new '0.2.0'
5
5
  end
6
6
 
7
7
  module VERSION #:nodoc:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_domain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Reischuck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-11 00:00:00.000000000 Z
11
+ date: 2013-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_event
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.0
19
+ version: 0.2.0
20
20
  type: :runtime
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.1.0
26
+ version: 0.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -128,6 +128,9 @@ extra_rdoc_files: []
128
128
  files:
129
129
  - app/models/active_domain/event.rb
130
130
  - app/models/active_domain/event_repository.rb
131
+ - app/models/active_domain/unique_command_id.rb
132
+ - app/models/active_domain/unique_command_id_repository.rb
133
+ - db/migrate/02_create_unique_command_ids.rb
131
134
  - lib/active_domain/autoload.rb
132
135
  - lib/active_domain/command_processor.rb
133
136
  - lib/active_domain/command_routes.rb