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 +4 -4
- data/README.md +5 -9
- data/app/models/concerns/rails_simple_event_sourcing/read_only.rb +4 -0
- data/app/models/rails_simple_event_sourcing/event.rb +5 -1
- data/config/routes.rb +2 -2
- data/lib/rails_simple_event_sourcing/engine.rb +1 -0
- data/lib/rails_simple_event_sourcing/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3de0a8a9ff2169679636b2f07ecbeb3c665bfd6a7167f564029c343d508dbcc0
|
|
4
|
+
data.tar.gz: 136e1bb962428462dd0921cefa63746beefb6efab578f6c8a0e018709f10da1f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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: "/
|
|
551
|
+
mount RailsSimpleEventSourcing::Engine, at: "/events"
|
|
552
552
|
end
|
|
553
553
|
```
|
|
554
554
|
|
|
555
|
-
Then navigate to `/
|
|
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
|
-
"
|
|
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: "/
|
|
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: "/
|
|
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
|
|
@@ -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
|
-
|
|
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
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.
|
|
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-
|
|
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
|