aggregate_root 0.43.0 → 0.44.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: 6722a27002d1414528635db8339fe8a9d38f3c302a9a6aa20c0e7b744e8adc99
4
- data.tar.gz: da630b00d7edc68443d36cdd708e73fa287e0f9db5ab482f37e02e2b00d0edb4
3
+ metadata.gz: 9d97ed4868f7bee41c067e0e0a74363723214c66c99eb46d77c41633e24cb448
4
+ data.tar.gz: 47077688e5116a63e5d162584b7ec285cf0cb904694c0409d04f8d2ba397d3a7
5
5
  SHA512:
6
- metadata.gz: f9d88d9b7d598db1d1cbb8266f7d86874271e6670767290657658d4cdc1993091e9600ed056a03d87d51d98b09453d67d11ade190c5fb31f66bafa364cce8d6a
7
- data.tar.gz: 1ca037cc094889c0d213f84a59530c49974c5823df285389460ec1a5bd1c04d9f0bc2e39176ebb3f3f909366af5f9172d0e376849280b287018abbd8a7b3466b
6
+ metadata.gz: 38f9b25a3cd385a9053fa3d5785b5f176041b7a4b05c55e43c0e825bac8cbf82036cdbc864d4f7c4f74f7a44c656e4efa4a13fbf2f82e51a580c5369c79259c7
7
+ data.tar.gz: 2253844d8a27555cadc1f47b74e7687a53fb340c0155948a893d455662e0f1fd6909607ad72debb118deff02ef3e8c37f8687277049f9cbd4facd9f11f2aab20
data/README.md CHANGED
@@ -2,123 +2,4 @@
2
2
 
3
3
  Event sourced (with Rails Event Store) aggregate root implementation.
4
4
 
5
- ## Installation
6
-
7
- * Add following line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'aggregate_root'
11
- ```
12
-
13
- ## Before use
14
-
15
- Choose your weapon now! Ekhm I mean choose your event store client.
16
- To do so add configuration in environment setup. Example using [RailsEventStore](https://github.com/RailsEventStore/rails_event_store/):
17
-
18
- ```ruby
19
- AggregateRoot.configure do |config|
20
- config.default_event_store = RailsEventStore::Client.new
21
- end
22
- ```
23
-
24
- Remember that this is only a default event store used by `AggregateRoot` module when no event store is given in `load` / `store` methods parameters.
25
-
26
- To use [RailsEventStore](https://github.com/RailsEventStore/rails_event_store/) add to Gemfile:
27
-
28
- ```ruby
29
- gem 'rails_event_store'
30
- ```
31
-
32
- Then setup [RailsEventStore](https://github.com/RailsEventStore/rails_event_store/) as described in
33
- the [docs](https://railseventstore.org/docs/install/)
34
-
35
- ## Usage
36
-
37
- To create a new aggregate domain object include `AggregateRoot::Base` module.
38
- It is important to assign `id` at initializer - it will be used as a event store stream name.
39
-
40
- ```ruby
41
- class Order
42
- include AggregateRoot
43
-
44
- # ... more later
45
- end
46
- ```
47
-
48
- #### Define aggregate logic
49
-
50
- ```ruby
51
- OrderSubmitted = Class.new(RailsEventStore::Event)
52
- OrderExpired = Class.new(RailsEventStore::Event)
53
- ```
54
-
55
- ```ruby
56
- class Order
57
- include AggregateRoot
58
- HasBeenAlreadySubmitted = Class.new(StandardError)
59
- HasExpired = Class.new(StandardError)
60
-
61
- def initialize
62
- self.state = :new
63
- # any other code here
64
- end
65
-
66
- def submit
67
- raise HasBeenAlreadySubmitted if state == :submitted
68
- raise HasExpired if state == :expired
69
- apply OrderSubmitted.new(data: {delivery_date: Time.now + 24.hours})
70
- end
71
-
72
- def expire
73
- apply OrderExpired.new
74
- end
75
-
76
- private
77
- attr_accessor :state
78
-
79
- def apply_order_submitted(event)
80
- self.state = :submitted
81
- end
82
-
83
- def apply_order_expired(event)
84
- self.state = :expired
85
- end
86
- end
87
- ```
88
-
89
- #### Loading an aggregate root object from event store
90
-
91
- ```ruby
92
- stream_name = "Order$123"
93
- order = Order.new.load(stream_name)
94
- ```
95
-
96
- Load gets all domain event stored for the aggregate in event store and apply them
97
- in order to given aggregate to rebuild aggregate's state.
98
-
99
- #### Storing an aggregate root's changes in event store
100
-
101
- ```ruby
102
- stream_name = "Order$123"
103
- order = Order.new.load(stream_name)
104
- order.submit
105
- order.store
106
- ```
107
-
108
- Store gets all unpublished aggregate's domain events (created by executing a domain logic method like `submit`)
109
- and publish them in order of creation to event store. If `stream_name` is not specified events will be stored
110
- in the same stream from which order has been loaded.
111
-
112
- #### Resources
113
-
114
- There're already few blog posts about building an event sourced applications with [rails_event_store](https://github.com/RailsEventStore/rails_event_store) and aggregate_root gems:
115
-
116
- * [Why use Event Sourcing](https://blog.arkency.com/2015/03/why-use-event-sourcing/)
117
- * [The Event Store for Rails developers](https://blog.arkency.com/2015/04/the-event-store-for-rails-developers/)
118
- * [Fast introduction to Event Sourcing for Ruby programmers](https://blog.arkency.com/2015/03/fast-introduction-to-event-sourcing-for-ruby-programmers/)
119
- * [Building an Event Sourced application using rails_event_store](https://blog.arkency.com/2015/05/building-an-event-sourced-application-using-rails-event-store/)
120
- * [Using domain events as success/failure messages](https://blog.arkency.com/2015/05/using-domain-events-as-success-slash-failure-messages/)
121
- * [Subscribing for events in rails_event_store](https://blog.arkency.com/2015/06/subscribing-for-events-in-rails-event-store/)
122
- * [Testing an Event Sourced application](https://blog.arkency.com/2015/07/testing-event-sourced-application/)
123
- * [Testing Event Sourced application - the read side](https://blog.arkency.com/2015/09/testing-event-sourced-application-the-read-side/)
124
- * [One event to rule them all](https://blog.arkency.com/2016/01/one-event-to-rule-them-all/)
5
+ For configuration & usage documentation see [Event Sourcing with AggregateRoot](https://railseventstore.org/docs/app/).
@@ -26,5 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
27
  spec.require_paths = ['lib']
28
28
 
29
- spec.add_dependency 'ruby_event_store', '= 0.43.0'
29
+ spec.add_dependency 'ruby_event_store', '= 0.44.0'
30
30
  end
@@ -20,7 +20,7 @@ module AggregateRoot
20
20
  private
21
21
 
22
22
  def handler_name(aggregate, event)
23
- on_dsl_handler_name(aggregate, event.type) || apply_handler_name(event.type)
23
+ on_dsl_handler_name(aggregate, event.event_type) || apply_handler_name(event.event_type)
24
24
  end
25
25
 
26
26
  def on_dsl_handler_name(aggregate, event_type)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AggregateRoot
4
- VERSION = "0.43.0"
4
+ VERSION = "0.44.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aggregate_root
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.44.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-26 00:00:00.000000000 Z
11
+ date: 2020-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby_event_store
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.43.0
19
+ version: 0.44.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: 0.43.0
26
+ version: 0.44.0
27
27
  description: Event sourced (with Rails Event Store) aggregate root implementation
28
28
  email:
29
29
  - dev@arkency.com