-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abbbb91
commit d15e9c1
Showing
4 changed files
with
30 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require_relative "../../../shared/lib/project_management" | ||
require_relative "project_management/issue" | ||
require_relative "project_management/repository" | ||
require_relative "project_management/issue_projection" | ||
require_relative "project_management/handler" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 2 additions & 8 deletions
10
examples/query_based/lib/project_management/issue_projection.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module ProjectManagement | ||
class Repository | ||
def initialize(event_store) | ||
@event_store = event_store | ||
end | ||
|
||
def load(id, initial_state) | ||
query = | ||
@event_store | ||
.read | ||
.stream(stream_name(id)) | ||
IssueProjection.call(query, initial_state) | ||
end | ||
|
||
def store(id, events) | ||
@event_store.append(events, stream_name: stream_name(id)) | ||
end | ||
|
||
private | ||
|
||
def stream_name(id) = "Issue$#{id}" | ||
end | ||
end |