rails_event_store_active_record 2.3.0 → 2.4.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
  SHA256:
3
- metadata.gz: 47f9fb4041eeafab89312eabfbf9cada70da41480032fef06dcf3311f0e35d56
4
- data.tar.gz: 79e021816506f4e49ff72e6f66f66820c9d588a30d1f3f8736d29cc478400340
3
+ metadata.gz: b146f907eef70a988c0949381dbf897a4f93bd7aa9e1ccf8346559c2656feb80
4
+ data.tar.gz: 46b6f4ce8d62b7386d72a1219a375e012bd3d15b33b16fe552cb8adee9f4f6e4
5
5
  SHA512:
6
- metadata.gz: cfc072dd9e99031459dcc037cece006477f08c8b5ec014b592f579b3de403e57b7224a68691548b6e2e1b1d0d735aba841cb7a969f0d22916b8165360f4d64df
7
- data.tar.gz: 440e6a1a06e37a05ec12590de43be4445314c8244d480f8a8a2ad261e5adcce05e5aa2115a9001011fcb063779ab6a74ff4e518dc0a463812bebe0eea67c50ff
6
+ metadata.gz: 0be237c7518c776a5ee19e8625f39966a20f255b0076839695957df0aa337c181bc7c85351afb2a1fbffdd6b0fd75fa50217482c30d1aa82437b242a32552e8d
7
+ data.tar.gz: 32aa1160ba4de4081357319e25012330249b6e946d0e0b558452fe41e7a30aa25e70d65faf9897ba6b7afac841c6b2ea6011117a892a272179da58b38a96bbb4
data/README.md CHANGED
@@ -4,4 +4,4 @@ Persistent event repository implementation for RubyEventStore based on ActiveRec
4
4
 
5
5
  Includes repository implementation with linearized writes to achieve log-like properties of streams on top of SQL database engine.
6
6
 
7
- Find out more at [https://railseventstore.org](https://railseventstore.org/)
7
+ Find out more at [https://railseventstore.org](https://railseventstore.org/)
@@ -3,9 +3,9 @@
3
3
  module RailsEventStoreActiveRecord
4
4
  class BatchEnumerator
5
5
  def initialize(batch_size, total_limit, reader)
6
- @batch_size = batch_size
6
+ @batch_size = batch_size
7
7
  @total_limit = total_limit
8
- @reader = reader
8
+ @reader = reader
9
9
  end
10
10
 
11
11
  def each
@@ -13,7 +13,7 @@ module RailsEventStoreActiveRecord
13
13
  offset_id = nil
14
14
 
15
15
  0.step(total_limit - 1, batch_size) do |batch_offset|
16
- batch_limit = [batch_size, total_limit - batch_offset].min
16
+ batch_limit = [batch_size, total_limit - batch_offset].min
17
17
  results, offset_id = reader.call(offset_id, batch_limit)
18
18
 
19
19
  break if results.empty?
@@ -34,4 +34,3 @@ module RailsEventStoreActiveRecord
34
34
  attr_reader :batch_size, :total_limit, :reader
35
35
  end
36
36
  end
37
-
@@ -1,14 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/core_ext/array"
4
- require "activerecord-import"
5
4
 
6
5
  module RailsEventStoreActiveRecord
7
6
  class EventRepository
8
7
  POSITION_SHIFT = 1
9
8
 
10
9
  def initialize(model_factory: WithDefaultModels.new, serializer:)
11
- @serializer = serializer
10
+ @serializer = serializer
12
11
 
13
12
  @event_klass, @stream_klass = model_factory.call
14
13
  @repo_reader = EventRepositoryReader.new(@event_klass, @stream_klass, serializer)
@@ -16,15 +15,13 @@ module RailsEventStoreActiveRecord
16
15
  end
17
16
 
18
17
  def append_to_stream(records, stream, expected_version)
19
- hashes = []
18
+ hashes = []
20
19
  event_ids = []
21
20
  records.each do |record|
22
- hashes << import_hash(record, record.serialize(serializer))
21
+ hashes << insert_hash(record, record.serialize(serializer))
23
22
  event_ids << record.event_id
24
23
  end
25
- add_to_stream(event_ids, stream, expected_version) do
26
- @event_klass.import(hashes)
27
- end
24
+ add_to_stream(event_ids, stream, expected_version) { @event_klass.insert_all!(hashes) }
28
25
  end
29
26
 
30
27
  def link_to_stream(event_ids, stream, expected_version)
@@ -55,13 +52,20 @@ module RailsEventStoreActiveRecord
55
52
  end
56
53
 
57
54
  def update_messages(records)
58
- hashes = records.map { |record| import_hash(record, record.serialize(serializer)) }
55
+ hashes = records.map { |record| upsert_hash(record, record.serialize(serializer)) }
59
56
  for_update = records.map(&:event_id)
60
57
  start_transaction do
61
- existing = @event_klass.where(event_id: for_update).pluck(:event_id, :id).to_h
62
- (for_update - existing.keys).each{|id| raise RubyEventStore::EventNotFound.new(id) }
63
- hashes.each { |h| h[:id] = existing.fetch(h.fetch(:event_id)) }
64
- @event_klass.import(hashes, on_duplicate_key_update: [:data, :metadata, :event_type, :valid_at])
58
+ existing =
59
+ @event_klass
60
+ .where(event_id: for_update)
61
+ .pluck(:event_id, :id, :created_at)
62
+ .reduce({}) { |acc, (event_id, id, created_at)| acc.merge(event_id => [id, created_at]) }
63
+ (for_update - existing.keys).each { |id| raise RubyEventStore::EventNotFound.new(id) }
64
+ hashes.each do |h|
65
+ h[:id] = existing.fetch(h.fetch(:event_id)).at(0)
66
+ h[:created_at] = existing.fetch(h.fetch(:event_id)).at(1)
67
+ end
68
+ @event_klass.upsert_all(hashes)
65
69
  end
66
70
  end
67
71
 
@@ -77,23 +81,32 @@ module RailsEventStoreActiveRecord
77
81
  @repo_reader.global_position(event_id)
78
82
  end
79
83
 
84
+ def event_in_stream?(event_id, stream)
85
+ @repo_reader.event_in_stream?(event_id, stream)
86
+ end
87
+
80
88
  private
89
+
81
90
  attr_reader :serializer
82
91
 
83
92
  def add_to_stream(event_ids, stream, expected_version)
84
- last_stream_version = ->(stream_) { @stream_klass.where(stream: stream_.name).order("position DESC").first.try(:position) }
93
+ last_stream_version = ->(stream_) do
94
+ @stream_klass.where(stream: stream_.name).order("position DESC").first.try(:position)
95
+ end
85
96
  resolved_version = expected_version.resolve_for(stream, last_stream_version)
86
97
 
87
98
  start_transaction do
88
99
  yield if block_given?
89
- in_stream = event_ids.map.with_index do |event_id, index|
90
- {
91
- stream: stream.name,
92
- position: compute_position(resolved_version, index),
93
- event_id: event_id,
94
- }
95
- end
96
- @stream_klass.import(in_stream) unless stream.global?
100
+ in_stream =
101
+ event_ids.map.with_index do |event_id, index|
102
+ {
103
+ stream: stream.name,
104
+ position: compute_position(resolved_version, index),
105
+ event_id: event_id,
106
+ created_at: Time.now.utc
107
+ }
108
+ end
109
+ @stream_klass.insert_all!(in_stream) unless stream.global?
97
110
  end
98
111
  self
99
112
  rescue ActiveRecord::RecordNotUnique => e
@@ -101,30 +114,36 @@ module RailsEventStoreActiveRecord
101
114
  end
102
115
 
103
116
  def raise_error(e)
104
- if detect_index_violated(e.message)
105
- raise RubyEventStore::EventDuplicatedInStream
106
- end
117
+ raise RubyEventStore::EventDuplicatedInStream if detect_index_violated(e.message)
107
118
  raise RubyEventStore::WrongExpectedEventVersion
108
119
  end
109
120
 
110
121
  def compute_position(resolved_version, index)
111
- unless resolved_version.nil?
112
- resolved_version + index + POSITION_SHIFT
113
- end
122
+ resolved_version + index + POSITION_SHIFT unless resolved_version.nil?
114
123
  end
115
124
 
116
125
  def detect_index_violated(message)
117
126
  @index_violation_detector.detect(message)
118
127
  end
119
128
 
120
- def import_hash(record, serialized_record)
129
+ def insert_hash(record, serialized_record)
121
130
  {
122
- event_id: serialized_record.event_id,
123
- data: serialized_record.data,
124
- metadata: serialized_record.metadata,
131
+ event_id: serialized_record.event_id,
132
+ data: serialized_record.data,
133
+ metadata: serialized_record.metadata,
125
134
  event_type: serialized_record.event_type,
126
135
  created_at: record.timestamp,
127
- valid_at: optimize_timestamp(record.valid_at, record.timestamp),
136
+ valid_at: optimize_timestamp(record.valid_at, record.timestamp)
137
+ }
138
+ end
139
+
140
+ def upsert_hash(record, serialized_record)
141
+ {
142
+ event_id: serialized_record.event_id,
143
+ data: serialized_record.data,
144
+ metadata: serialized_record.metadata,
145
+ event_type: serialized_record.event_type,
146
+ valid_at: optimize_timestamp(record.valid_at, record.timestamp)
128
147
  }
129
148
  end
130
149
 
@@ -136,5 +155,4 @@ module RailsEventStoreActiveRecord
136
155
  @event_klass.transaction(requires_new: true, &block)
137
156
  end
138
157
  end
139
-
140
158
  end
@@ -2,7 +2,6 @@
2
2
 
3
3
  module RailsEventStoreActiveRecord
4
4
  class EventRepositoryReader
5
-
6
5
  def initialize(event_klass, stream_klass, serializer)
7
6
  @event_klass = event_klass
8
7
  @stream_klass = stream_klass
@@ -38,9 +37,7 @@ module RailsEventStoreActiveRecord
38
37
  end
39
38
 
40
39
  def streams_of(event_id)
41
- @stream_klass.where(event_id: event_id)
42
- .pluck(:stream)
43
- .map { |name| RubyEventStore::Stream.new(name) }
40
+ @stream_klass.where(event_id: event_id).pluck(:stream).map { |name| RubyEventStore::Stream.new(name) }
44
41
  end
45
42
 
46
43
  def position_in_stream(event_id, stream)
@@ -55,23 +52,28 @@ module RailsEventStoreActiveRecord
55
52
  record.id - 1
56
53
  end
57
54
 
55
+ def event_in_stream?(event_id, stream)
56
+ @stream_klass.where(event_id: event_id, stream: stream.name).exists?
57
+ end
58
+
58
59
  private
60
+
59
61
  attr_reader :serializer
60
62
 
61
63
  def offset_limit_batch_reader(spec, stream)
62
- batch_reader = ->(offset, limit) do
63
- stream
64
- .offset(offset)
65
- .limit(limit)
66
- .map(&method(:record))
67
- end
64
+ batch_reader = ->(offset, limit) { stream.offset(offset).limit(limit).map(&method(:record)) }
68
65
  RubyEventStore::BatchEnumerator.new(spec.batch_size, spec.limit, batch_reader).each
69
66
  end
70
67
 
71
68
  def monotonic_id_batch_reader(spec, stream)
72
69
  batch_reader = ->(offset_id, limit) do
73
70
  search_in = spec.stream.global? ? @event_klass.table_name : @stream_klass.table_name
74
- records = offset_id.nil? ? stream.limit(limit) : stream.where(start_offset_condition(spec, offset_id, search_in)).limit(limit)
71
+ records =
72
+ if offset_id.nil?
73
+ stream.limit(limit)
74
+ else
75
+ stream.where(start_offset_condition(spec, offset_id, search_in)).limit(limit)
76
+ end
75
77
  [records.map(&method(:record)), records.last]
76
78
  end
77
79
  BatchEnumerator.new(spec.batch_size, spec.limit, batch_reader).each
@@ -80,29 +82,29 @@ module RailsEventStoreActiveRecord
80
82
  def read_scope(spec)
81
83
  if spec.stream.global?
82
84
  stream = @event_klass
83
- stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
84
- stream = stream.where(event_type: spec.with_types) if spec.with_types?
85
+ stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
86
+ stream = stream.where(event_type: spec.with_types) if spec.with_types?
85
87
  stream = ordered(stream, spec)
86
- stream = stream.limit(spec.limit) if spec.limit?
87
- stream = stream.where(start_condition_in_global_stream(spec)) if spec.start
88
- stream = stream.where(stop_condition_in_global_stream(spec)) if spec.stop
89
- stream = stream.where(older_than_condition(spec)) if spec.older_than
88
+ stream = stream.limit(spec.limit) if spec.limit?
89
+ stream = stream.where(start_condition_in_global_stream(spec)) if spec.start
90
+ stream = stream.where(stop_condition_in_global_stream(spec)) if spec.stop
91
+ stream = stream.where(older_than_condition(spec)) if spec.older_than
90
92
  stream = stream.where(older_than_or_equal_condition(spec)) if spec.older_than_or_equal
91
- stream = stream.where(newer_than_condition(spec)) if spec.newer_than
93
+ stream = stream.where(newer_than_condition(spec)) if spec.newer_than
92
94
  stream = stream.where(newer_than_or_equal_condition(spec)) if spec.newer_than_or_equal
93
95
  stream.order(id: order(spec))
94
96
  else
95
97
  stream = @stream_klass.preload(:event).where(stream: spec.stream.name)
96
- stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
97
- stream = stream.where(@event_klass.table_name => {event_type: spec.with_types}) if spec.with_types?
98
+ stream = stream.where(event_id: spec.with_ids) if spec.with_ids?
99
+ stream = stream.where(@event_klass.table_name => { event_type: spec.with_types }) if spec.with_types?
98
100
  stream = ordered(stream.joins(:event), spec)
99
101
  stream = stream.order(id: order(spec))
100
- stream = stream.limit(spec.limit) if spec.limit?
101
- stream = stream.where(start_condition(spec)) if spec.start
102
- stream = stream.where(stop_condition(spec)) if spec.stop
103
- stream = stream.where(older_than_condition(spec)) if spec.older_than
102
+ stream = stream.limit(spec.limit) if spec.limit?
103
+ stream = stream.where(start_condition(spec)) if spec.start
104
+ stream = stream.where(stop_condition(spec)) if spec.stop
105
+ stream = stream.where(older_than_condition(spec)) if spec.older_than
104
106
  stream = stream.where(older_than_or_equal_condition(spec)) if spec.older_than_or_equal
105
- stream = stream.where(newer_than_condition(spec)) if spec.newer_than
107
+ stream = stream.where(newer_than_condition(spec)) if spec.newer_than
106
108
  stream = stream.where(newer_than_or_equal_condition(spec)) if spec.newer_than_or_equal
107
109
  stream
108
110
  end
@@ -120,37 +122,41 @@ module RailsEventStoreActiveRecord
120
122
  end
121
123
 
122
124
  def start_offset_condition(specification, record_id, search_in)
123
- condition = "#{search_in}.id #{specification.forward? ? '>' : '<'} ?"
125
+ condition = "#{search_in}.id #{specification.forward? ? ">" : "<"} ?"
124
126
  [condition, record_id]
125
127
  end
126
128
 
127
129
  def stop_offset_condition(specification, record_id, search_in)
128
- condition = "#{search_in}.id #{specification.forward? ? '<' : '>'} ?"
130
+ condition = "#{search_in}.id #{specification.forward? ? "<" : ">"} ?"
129
131
  [condition, record_id]
130
132
  end
131
133
 
132
134
  def start_condition(specification)
133
- start_offset_condition(specification,
135
+ start_offset_condition(
136
+ specification,
134
137
  @stream_klass.find_by!(event_id: specification.start, stream: specification.stream.name),
135
- @stream_klass.table_name)
138
+ @stream_klass.table_name
139
+ )
136
140
  end
137
141
 
138
142
  def stop_condition(specification)
139
- stop_offset_condition(specification,
143
+ stop_offset_condition(
144
+ specification,
140
145
  @stream_klass.find_by!(event_id: specification.stop, stream: specification.stream.name),
141
- @stream_klass.table_name)
146
+ @stream_klass.table_name
147
+ )
142
148
  end
143
149
 
144
150
  def start_condition_in_global_stream(specification)
145
- start_offset_condition(specification,
151
+ start_offset_condition(
152
+ specification,
146
153
  @event_klass.find_by!(event_id: specification.start),
147
- @event_klass.table_name)
154
+ @event_klass.table_name
155
+ )
148
156
  end
149
157
 
150
158
  def stop_condition_in_global_stream(specification)
151
- stop_offset_condition(specification,
152
- @event_klass.find_by!(event_id: specification.stop),
153
- @event_klass.table_name)
159
+ stop_offset_condition(specification, @event_klass.find_by!(event_id: specification.stop), @event_klass.table_name)
154
160
  end
155
161
 
156
162
  def older_than_condition(specification)
@@ -176,14 +182,16 @@ module RailsEventStoreActiveRecord
176
182
  def record(record)
177
183
  record = record.event if @stream_klass === record
178
184
 
179
- RubyEventStore::SerializedRecord.new(
180
- event_id: record.event_id,
181
- metadata: record.metadata,
182
- data: record.data,
183
- event_type: record.event_type,
184
- timestamp: record.created_at.iso8601(RubyEventStore::TIMESTAMP_PRECISION),
185
- valid_at: (record.valid_at || record.created_at).iso8601(RubyEventStore::TIMESTAMP_PRECISION),
186
- ).deserialize(serializer)
185
+ RubyEventStore::SerializedRecord
186
+ .new(
187
+ event_id: record.event_id,
188
+ metadata: record.metadata,
189
+ data: record.data,
190
+ event_type: record.event_type,
191
+ timestamp: record.created_at.iso8601(RubyEventStore::TIMESTAMP_PRECISION),
192
+ valid_at: (record.valid_at || record.created_at).iso8601(RubyEventStore::TIMESTAMP_PRECISION)
193
+ )
194
+ .deserialize(serializer)
187
195
  end
188
196
  end
189
197
 
@@ -7,16 +7,18 @@ end
7
7
 
8
8
  module RailsEventStoreActiveRecord
9
9
  class MigrationGenerator < Rails::Generators::Base
10
- class Error < Thor::Error; end
10
+ class Error < Thor::Error
11
+ end
11
12
 
12
- DATA_TYPES = %w(binary json jsonb).freeze
13
+ DATA_TYPES = %w[binary json jsonb].freeze
13
14
 
14
15
  source_root File.expand_path(File.join(File.dirname(__FILE__), "../generators/templates"))
15
16
  class_option(
16
17
  :data_type,
17
18
  type: :string,
18
19
  default: "binary",
19
- desc: "Configure the data type for `data` and `meta data` fields in Postgres migration (options: #{DATA_TYPES.join('/')})"
20
+ desc:
21
+ "Configure the data type for `data` and `meta data` fields in Postgres migration (options: #{DATA_TYPES.join("/")})"
20
22
  )
21
23
 
22
24
  def initialize(*args)
@@ -45,4 +47,4 @@ module RailsEventStoreActiveRecord
45
47
  Time.now.strftime("%Y%m%d%H%M%S")
46
48
  end
47
49
  end
48
- end if defined?(Rails::Generators::Base)
50
+ end if defined?(Rails::Generators::Base)
@@ -2,41 +2,37 @@
2
2
 
3
3
  module RailsEventStoreActiveRecord
4
4
  class IndexViolationDetector
5
-
6
5
  def initialize(event_store_events, event_store_events_in_streams)
7
- @postgres_pkey_error = "Key (event_id)".freeze
6
+ @postgres_pkey_error = "Key (event_id)".freeze
8
7
  @postgres_index_error = "Key (stream, event_id)".freeze
9
- @mysql5_pkey_error = "for key 'index_#{event_store_events}_on_event_id'".freeze
10
- @mysql8_pkey_error = "for key '#{event_store_events}.index_#{event_store_events}_on_event_id'".freeze
11
- @mysql5_index_error = "for key 'index_#{event_store_events_in_streams}_on_stream_and_event_id'".freeze
12
- @mysql8_index_error = "for key '#{event_store_events_in_streams}.index_#{event_store_events_in_streams}_on_stream_and_event_id'".freeze
13
- @sqlite3_pkey_error = "constraint failed: #{event_store_events}.event_id".freeze
14
- @sqlite3_index_error = "constraint failed: #{event_store_events_in_streams}.stream, #{event_store_events_in_streams}.event_id".freeze
8
+ @mysql5_pkey_error = "for key 'index_#{event_store_events}_on_event_id'".freeze
9
+ @mysql8_pkey_error = "for key '#{event_store_events}.index_#{event_store_events}_on_event_id'".freeze
10
+ @mysql5_index_error = "for key 'index_#{event_store_events_in_streams}_on_stream_and_event_id'".freeze
11
+ @mysql8_index_error =
12
+ "for key '#{event_store_events_in_streams}.index_#{event_store_events_in_streams}_on_stream_and_event_id'"
13
+ .freeze
14
+ @sqlite3_pkey_error = "constraint failed: #{event_store_events}.event_id".freeze
15
+ @sqlite3_index_error =
16
+ "constraint failed: #{event_store_events_in_streams}.stream, #{event_store_events_in_streams}.event_id".freeze
15
17
  end
16
18
 
17
19
  def detect(message)
18
- detect_postgres(message) ||
19
- detect_mysql(message) ||
20
- detect_sqlite(message)
20
+ detect_postgres(message) || detect_mysql(message) || detect_sqlite(message)
21
21
  end
22
22
 
23
23
  private
24
24
 
25
25
  def detect_postgres(message)
26
- message.include?(@postgres_pkey_error) ||
27
- message.include?(@postgres_index_error)
26
+ message.include?(@postgres_pkey_error) || message.include?(@postgres_index_error)
28
27
  end
29
28
 
30
29
  def detect_mysql(message)
31
- message.include?(@mysql5_pkey_error) ||
32
- message.include?(@mysql8_pkey_error) ||
33
- message.include?(@mysql5_index_error) ||
34
- message.include?(@mysql8_index_error)
30
+ message.include?(@mysql5_pkey_error) || message.include?(@mysql8_pkey_error) ||
31
+ message.include?(@mysql5_index_error) || message.include?(@mysql8_index_error)
35
32
  end
36
33
 
37
34
  def detect_sqlite(message)
38
- message.include?(@sqlite3_pkey_error) ||
39
- message.include?(@sqlite3_index_error)
35
+ message.include?(@sqlite3_pkey_error) || message.include?(@sqlite3_index_error)
40
36
  end
41
37
  end
42
38
 
@@ -1,20 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "activerecord-import"
4
-
5
3
  module RailsEventStoreActiveRecord
6
4
  class PgLinearizedEventRepository < EventRepository
7
-
8
5
  def start_transaction(&proc)
9
6
  ActiveRecord::Base.transaction(requires_new: true) do
10
- ActiveRecord::Base
11
- .connection
12
- .execute("SELECT pg_advisory_xact_lock(1845240511599988039) as l")
13
- .each{}
7
+ ActiveRecord::Base.connection.execute("SELECT pg_advisory_xact_lock(1845240511599988039) as l").each {}
14
8
 
15
9
  proc.call
16
10
  end
17
11
  end
18
-
19
12
  end
20
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsEventStoreActiveRecord
4
- VERSION = "2.3.0"
4
+ VERSION = "2.4.0"
5
5
  end
@@ -3,31 +3,31 @@
3
3
  module RailsEventStoreActiveRecord
4
4
  class WithAbstractBaseClass
5
5
  def initialize(base_klass)
6
- raise ArgumentError.new(
7
- "#{base_klass} must be an abstract class that inherits from ActiveRecord::Base"
8
- ) unless base_klass < ActiveRecord::Base && base_klass.abstract_class?
6
+ unless base_klass < ActiveRecord::Base && base_klass.abstract_class?
7
+ raise ArgumentError.new("#{base_klass} must be an abstract class that inherits from ActiveRecord::Base")
8
+ end
9
9
  @base_klass = base_klass
10
10
  end
11
11
 
12
12
  def call(instance_id: SecureRandom.hex)
13
- [
14
- build_event_klass(instance_id),
15
- build_stream_klass(instance_id),
16
- ]
13
+ [build_event_klass(instance_id), build_stream_klass(instance_id)]
17
14
  end
18
15
 
19
16
  private
17
+
20
18
  def build_event_klass(instance_id)
21
- Object.const_set("Event_#{instance_id}",
19
+ Object.const_set(
20
+ "Event_#{instance_id}",
22
21
  Class.new(@base_klass) do
23
22
  self.primary_key = :id
24
- self.table_name = "event_store_events"
23
+ self.table_name = "event_store_events"
25
24
  end
26
25
  )
27
26
  end
28
27
 
29
28
  def build_stream_klass(instance_id)
30
- Object.const_set("EventInStream_#{instance_id}",
29
+ Object.const_set(
30
+ "EventInStream_#{instance_id}",
31
31
  Class.new(@base_klass) do
32
32
  self.primary_key = :id
33
33
  self.table_name = "event_store_events_in_streams"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_event_store_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2022-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_event_store
@@ -16,42 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 2.3.0
19
+ version: 2.4.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: 2.3.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '5.0'
33
+ version: '6.0'
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
- version: '5.0'
41
- - !ruby/object:Gem::Dependency
42
- name: activerecord-import
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 1.0.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: 1.0.2
40
+ version: '6.0'
55
41
  description: |
56
42
  Persistent event repository implementation for RubyEventStore based on ActiveRecord. Ships with database schema
57
43
  and migrations suitable for PostgreSQL, MySQL ans SQLite database engines.
@@ -85,6 +71,7 @@ metadata:
85
71
  changelog_uri: https://github.com/RailsEventStore/rails_event_store/releases
86
72
  source_code_uri: https://github.com/RailsEventStore/rails_event_store
87
73
  bug_tracker_uri: https://github.com/RailsEventStore/rails_event_store/issues
74
+ rubygems_mfa_required: 'true'
88
75
  post_install_message:
89
76
  rdoc_options: []
90
77
  require_paths:
@@ -93,14 +80,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
80
  requirements:
94
81
  - - ">="
95
82
  - !ruby/object:Gem::Version
96
- version: '2.6'
83
+ version: '2.7'
97
84
  required_rubygems_version: !ruby/object:Gem::Requirement
98
85
  requirements:
99
86
  - - ">="
100
87
  - !ruby/object:Gem::Version
101
88
  version: '0'
102
89
  requirements: []
103
- rubygems_version: 3.1.4
90
+ rubygems_version: 3.3.7
104
91
  signing_key:
105
92
  specification_version: 4
106
93
  summary: Persistent event repository implementation for RubyEventStore based on ActiveRecord