-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* merge child async * lint * Update changeset.rbi * misc * add ruby 3.2 * bumping version * Update changelog.md
- Loading branch information
1 parent
c391dd0
commit 7dcde58
Showing
15 changed files
with
451 additions
and
87 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
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
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
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,28 @@ | ||
# typed: true | ||
|
||
class Changeset | ||
class AsyncChangeset | ||
class InconsistencyError < StandardError; end | ||
|
||
def initialize(changeset_wrapped_in_proc) | ||
@changeset_wrapped_in_proc = changeset_wrapped_in_proc | ||
@called = false | ||
end | ||
|
||
def db_operations | ||
changeset.send(:db_operations) | ||
end | ||
|
||
def events_collection | ||
changeset.send(:events_collection) | ||
end | ||
|
||
private | ||
|
||
def changeset | ||
@changeset ||= @changeset_wrapped_in_proc.call.tap do |result| | ||
raise InconsistencyError unless result.is_a?(::Changeset) | ||
end | ||
end | ||
end | ||
end |
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,45 @@ | ||
# typed: true | ||
|
||
class Changeset | ||
class DbOperationCollection | ||
def initialize | ||
@collection = [] | ||
end | ||
|
||
def add(persistence_handler) | ||
collection.push(persistence_handler) | ||
end | ||
|
||
def merge_child(db_operations) | ||
db_operations.collection.each do |db_operation| | ||
add(db_operation) | ||
end | ||
end | ||
|
||
def merge_child_async(async_change_set) | ||
add(async_change_set) | ||
self | ||
end | ||
|
||
def each(&block) | ||
collection.each do |element| | ||
case element | ||
when Changeset::AsyncChangeset | ||
element.db_operations.each do |operation| | ||
yield(operation) | ||
end | ||
else | ||
yield(element) | ||
end | ||
end | ||
end | ||
|
||
def ==(other) | ||
collection == other.collection | ||
end | ||
|
||
protected | ||
|
||
attr_reader :collection | ||
end | ||
end |
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ def dispatch(event) | |
end | ||
|
||
def known_event?(event_name) | ||
false | ||
end | ||
|
||
def class | ||
|
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# typed: strict | ||
|
||
class Changeset | ||
VERSION = "0.1.2" | ||
VERSION = "0.1.3" | ||
end |
Oops, something went wrong.