eventsimple 1.5.4 → 1.5.5

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
  SHA256:
3
- metadata.gz: fd1f9b77183b60cff86b901ea1a34cf689ee05fe91a3935c094a4cab2cd4f967
4
- data.tar.gz: 56cd7accb037d1e559440a3aa201118037e24b7a8de3db0c7716a501d234ea08
3
+ metadata.gz: 638911b3c3aa0a4b29937285f54ea9e5db19611aabf57fee632393ef19a9f673
4
+ data.tar.gz: 5cec4fe7771514cb6148bb2e775bd9305444c714615ad54019e6f391a934c985
5
5
  SHA512:
6
- metadata.gz: 8e94859b8dec11414e20e95f5fa2edf3e9ea209b1f99fa0efa8ffbb4aae7d0b84b35fe88f36808ef8d619d1b20513efa80ec33db82babd578ea1f632643e13f8
7
- data.tar.gz: c2ac0bf6dcf7a0ad10f23c9d8ebcd858e92f92050bc23851d4b0394a2c460eb26b508ac5712e713ae0ce7412b0b7daaea374b17f8ac2b72f10203a975bac79ec
6
+ metadata.gz: b1484e11a7940d47af9d8a954c879f763547466d86de126753bff0d87b77e7d32b90f8949383fc49afe782ac179214f483abdc68504af149b18ef9edd583f19d
7
+ data.tar.gz: 68ab2b38e21b0a99a018f483aec74b8dcafc1b7549f4ef36dd5007dc0c3a7847d66c052981e0d0dc6b8d74ce5e4f769b0d6e64e7a0f9b2e1a60d02ff0e7d5289
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## 1.5.5 - 2024-12-23
10
+ ### Changed
11
+ - Validate value and type of `aggregate_id` between Event and Entity
12
+
9
13
  ## 1.5.4 - 2024-12-05
10
14
  ### Changed
11
15
  - Rails 8.0 is supported
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- eventsimple (1.5.4)
4
+ eventsimple (1.5.5)
5
5
  concurrent-ruby (>= 1.2.3)
6
6
  dry-struct (~> 1.6)
7
7
  dry-types (~> 1.7)
@@ -185,7 +185,7 @@ GEM
185
185
  mini_mime (1.1.5)
186
186
  minitest (5.25.4)
187
187
  nenv (0.3.0)
188
- net-imap (0.5.1)
188
+ net-imap (0.5.4)
189
189
  date
190
190
  net-protocol
191
191
  net-pop (0.1.2)
@@ -336,7 +336,7 @@ GEM
336
336
  rubocop-rails (~> 2.26.0)
337
337
  stringio (3.1.2)
338
338
  thor (1.3.2)
339
- timeout (0.4.2)
339
+ timeout (0.4.3)
340
340
  treetop (1.6.12)
341
341
  polyglot (~> 0.3)
342
342
  tzinfo (2.0.6)
@@ -3,6 +3,18 @@ module Eventsimple
3
3
  DEFAULT_IGNORE_PROPS = %w[id lock_version].freeze
4
4
 
5
5
  def event_driven_by(event_klass, aggregate_id:, filter_attributes: [])
6
+ if defined?(event_klass._aggregate_id)
7
+ raise ArgumentError, "aggregate_id mismatch event:#{event_klass._aggregate_id} entity:#{aggregate_id}" if aggregate_id != event_klass._aggregate_id
8
+
9
+ begin
10
+ aggregate_column_type_in_event = event_klass.column_for_attribute(:aggregate_id).type
11
+ aggregate_column_type_in_entity = column_for_attribute(aggregate_id).type
12
+
13
+ raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
14
+ rescue ActiveRecord::NoDatabaseError
15
+ end
16
+ end
17
+
6
18
  has_many :events, class_name: event_klass.name.to_s,
7
19
  foreign_key: :aggregate_id,
8
20
  primary_key: aggregate_id,
@@ -18,6 +30,9 @@ module Eventsimple
18
30
  class_attribute :_filter_attributes
19
31
  self._filter_attributes = [aggregate_id] | Array.wrap(filter_attributes)
20
32
 
33
+ class_attribute :_aggregate_id
34
+ self._aggregate_id = aggregate_id
35
+
21
36
  # disable automatic timestamp updates
22
37
  self.record_timestamps = false
23
38
 
@@ -5,6 +5,18 @@ module Eventsimple
5
5
 
6
6
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
7
7
  def drives_events_for(aggregate_klass, aggregate_id:, events_namespace: nil)
8
+ if defined?(aggregate_klass._aggregate_id)
9
+ raise ArgumentError, "aggregate_id mismatch event:#{aggregate_id} entity:#{aggregate_klass._aggregate_id}" if aggregate_id != aggregate_klass._aggregate_id
10
+
11
+ begin
12
+ aggregate_column_type_in_event = aggregate_klass.column_for_attribute(aggregate_klass._aggregate_id).type unless aggregate_klass.attribute_names.blank?
13
+ aggregate_column_type_in_entity = column_for_attribute(:aggregate_id).type unless aggregate_klass.attribute_names.blank?
14
+
15
+ raise ArgumentError, "column type mismatch - event:#{aggregate_column_type_in_event} entity:#{aggregate_column_type_in_entity}" if aggregate_column_type_in_event != aggregate_column_type_in_entity
16
+ rescue ActiveRecord::NoDatabaseError
17
+ end
18
+ end
19
+
8
20
  class_attribute :_events_namespace
9
21
  self._events_namespace = events_namespace
10
22
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eventsimple
4
- VERSION = '1.5.4'
4
+ VERSION = '1.5.5'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventsimple
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: 1.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zulfiqar Ali
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-05 00:00:00.000000000 Z
11
+ date: 2025-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct