rails_simple_event_sourcing 1.0.7 → 1.0.8

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: 9415504de52817629c90a90ad0fff708ad8f829c768ed88485b8eae53f241c18
4
- data.tar.gz: 2344f7a06e5c3b9dca5d0b6c98b1526ad73088c59cde9a0c64f2b5cb6a227ec6
3
+ metadata.gz: 3de0a8a9ff2169679636b2f07ecbeb3c665bfd6a7167f564029c343d508dbcc0
4
+ data.tar.gz: 136e1bb962428462dd0921cefa63746beefb6efab578f6c8a0e018709f10da1f
5
5
  SHA512:
6
- metadata.gz: 3f2ec958c3dab2f9b398ed1bd0bfddec38fb13c720762ab57cc45c59091d9116f07af133601a19dae083ba5c40b32177cbfaa4809cb6af1a37cf569ed941693d
7
- data.tar.gz: 32b8d673ca804d1ef03e5e55a561011fd052d70789afc078b9f8c7becff373d310bb2d24da411e6fc8a2fa869720a3aad487fbc4a93c5290cc2ce9a4f4d81c4d
6
+ metadata.gz: fcd653bc3201aeb4cffca05df6f9819e3b8d9ee2eab08e60e35988438321bf6f6b15fb7d65d0940483f9087877f5f451645fc26f7e1fb31fb36e61a898760aee
7
+ data.tar.gz: 85449f552f258d5d2ccd43f238389769dafdf885d93beeb7f1e4f47280f1bbc9ab5acb8fa435e94a3ca9f0602af52677812f1c8dcffa85857277b977081f0fb7
data/README.md CHANGED
@@ -548,11 +548,11 @@ Mount the engine in your `config/routes.rb`:
548
548
 
549
549
  ```ruby
550
550
  Rails.application.routes.draw do
551
- mount RailsSimpleEventSourcing::Engine, at: "/event-store"
551
+ mount RailsSimpleEventSourcing::Engine, at: "/events"
552
552
  end
553
553
  ```
554
554
 
555
- Then navigate to `/event-store` in your browser to access the viewer.
555
+ Then navigate to `/events` in your browser to access the viewer.
556
556
 
557
557
  **Password Protection:**
558
558
 
@@ -564,11 +564,11 @@ In production you will likely want to restrict access to the events viewer.
564
564
  Rails.application.routes.draw do
565
565
  mount Rack::Auth::Basic.new(
566
566
  RailsSimpleEventSourcing::Engine,
567
- "Event Store"
567
+ "Events"
568
568
  ) { |username, password|
569
569
  ActiveSupport::SecurityUtils.secure_compare(username, "admin") &
570
570
  ActiveSupport::SecurityUtils.secure_compare(password, Rails.application.credentials.event_sourcing_password || "secret")
571
- }, at: "/event-store"
571
+ }, at: "/events"
572
572
  end
573
573
  ```
574
574
 
@@ -577,7 +577,7 @@ end
577
577
  ```ruby
578
578
  Rails.application.routes.draw do
579
579
  authenticate :user, ->(user) { user.admin? } do
580
- mount RailsSimpleEventSourcing::Engine, at: "/event-store"
580
+ mount RailsSimpleEventSourcing::Engine, at: "/events"
581
581
  end
582
582
  end
583
583
  ```
@@ -639,10 +639,6 @@ class Customer < ApplicationRecord
639
639
 
640
640
  scope :active, -> { where(deleted_at: nil) }
641
641
  scope :deleted, -> { where.not(deleted_at: nil) }
642
-
643
- def soft_delete
644
- update(deleted_at: Time.current)
645
- end
646
642
  end
647
643
 
648
644
  # Event
@@ -13,6 +13,10 @@ module RailsSimpleEventSourcing
13
13
  @write_access_enabled = true
14
14
  end
15
15
 
16
+ def disable_write_access!
17
+ @write_access_enabled = false
18
+ end
19
+
16
20
  private
17
21
 
18
22
  def write_access_enabled
@@ -14,10 +14,13 @@ module RailsSimpleEventSourcing
14
14
 
15
15
  before_validation :setup_for_create, on: :create
16
16
  before_save :persist_aggregate, if: :aggregate_defined?
17
+ after_create :disable_write_access!
17
18
 
18
19
  def apply(aggregate)
19
20
  payload.each do |key, value|
20
- aggregate.send("#{key}=", value) if aggregate.respond_to?("#{key}=")
21
+ raise "Unknown attribute '#{key}' on #{aggregate.class}" unless aggregate.respond_to?("#{key}=")
22
+
23
+ aggregate.send("#{key}=", value)
21
24
  end
22
25
  end
23
26
 
@@ -67,6 +70,7 @@ module RailsSimpleEventSourcing
67
70
 
68
71
  aggregate_repository.save!(@aggregate)
69
72
  self.aggregate_id = @aggregate.id
73
+ @aggregate.disable_write_access!
70
74
  end
71
75
 
72
76
  def aggregate_repository
data/config/routes.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RailsSimpleEventSourcing::Engine.routes.draw do
4
- resources :events, only: [:index, :show]
5
- root to: "events#index"
4
+ root to: "events#index", as: :events
5
+ get ":id", to: "events#show", as: :event
6
6
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'concurrent'
3
4
  require_relative 'aggregate_repository'
4
5
  require_relative 'command_handler'
5
6
  require_relative 'command_handlers/base'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsSimpleEventSourcing
4
- VERSION = '1.0.7'
4
+ VERSION = '1.0.8'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_simple_event_sourcing
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Damian Baćkowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-22 00:00:00.000000000 Z
11
+ date: 2026-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 7.1.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rubocop
43
57
  requirement: !ruby/object:Gem::Requirement