entity_store 0.5.0 → 0.6.0

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
  SHA1:
3
- metadata.gz: fe61bb0a1f75d4a0afc00d95c58f76ea103225c2
4
- data.tar.gz: 1cb734260b975de0d8ae19df7dae3e192bdedab3
3
+ metadata.gz: 2fd6deacb63e070d4f7052598ccc5e79679d1052
4
+ data.tar.gz: 4c3fcfb0cae2e37aaa699c39a3730dda39d9f217
5
5
  SHA512:
6
- metadata.gz: 3809a2cfd1b74fab8ee17a2d8e7a7b6c308bcb4902dda00d4f25eeb717b81c8c9ae0f41bbe4779ace91cf7485cd3f2a4223e43beb163ba2bb31d099cc209cfef
7
- data.tar.gz: 6d420cc18d130d5c79f6aca5cfa887e679de5a6611dcb5fad2965f239a91693877474bc5a505e513b3b6ef94ecc84e3d32dc72028dd3a39fe3daf1ac00618885
6
+ metadata.gz: 676503735ad66f25dd174831c840ac9ec2d42616783aeaed0c8ba37fe50c33c00cf1e227284d84d4e08e76de9280c0f7b094e990dbe445f7937e1975545de288
7
+ data.tar.gz: 00516945f8fd853b07c982c823da8e911d8fee23630ba2f0ab68d751f36c2f277225722ed1055b8e849eea3969b32d1bfe3d1642e90f9cf4b4d891571760e238
@@ -43,8 +43,8 @@ module EntityStore
43
43
  events.ensure_index([['_entity_id', Mongo::ASCENDING], ['entity_version', Mongo::ASCENDING], ['_id', Mongo::ASCENDING]])
44
44
  end
45
45
 
46
- def add_entity(entity)
47
- entities.insert('_type' => entity.class.name, 'version' => entity.version).to_s
46
+ def add_entity(entity, id = BSON::ObjectId.new)
47
+ entities.insert('_id' => id, '_type' => entity.class.name, 'version' => entity.version).to_s
48
48
  end
49
49
 
50
50
  def save_entity(entity)
@@ -85,9 +85,14 @@ module EntityStore
85
85
  end
86
86
 
87
87
  def add_events(items)
88
- docs = items.map do |event|
88
+ events_with_id = items.map { |e| [ BSON::ObjectId.new, e ] }
89
+ add_events_with_ids(events_with_id)
90
+ end
91
+
92
+ def add_events_with_ids(event_id_map)
93
+ docs = event_id_map.map do |id, event|
89
94
  {
90
- '_id' => BSON::ObjectId.new,
95
+ '_id' => id,
91
96
  '_type' => event.class.name,
92
97
  '_entity_id' => BSON::ObjectId.from_string(event.entity_id)
93
98
  }.merge(event.attributes)
@@ -1,3 +1,3 @@
1
1
  module EntityStore
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: entity_store
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Bird
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-11 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.8'
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
26
  version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bson
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: hatchet
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.2'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0.2'
55
55
  description: Event sourced entity store with a replaceable body
@@ -96,17 +96,17 @@ require_paths:
96
96
  - lib
97
97
  required_ruby_version: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - '>='
99
+ - - ">="
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  required_rubygems_version: !ruby/object:Gem::Requirement
103
103
  requirements:
104
- - - '>='
104
+ - - ">="
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
108
  rubyforge_project:
109
- rubygems_version: 2.4.8
109
+ rubygems_version: 2.6.6
110
110
  signing_key:
111
111
  specification_version: 4
112
112
  summary: Event sourced entity store with a replaceable body