Created
June 17, 2023 09:59
-
-
Save mostlyobvious/75ff4ee755777b4ce6d7879d811bcfb2 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require "bundler/inline" | |
require "json" | |
gemfile do | |
source "https://rubygems.org" | |
gem "rails_event_store", "2.9.1" | |
gem "railties", "~> 7.0.0" | |
end | |
IssueHasBeenPostedOnGithub = | |
Class.new(RailsEventStore::Event) | |
module RubyEventStore | |
class InMemoryRepository | |
attr_reader :storage | |
end | |
end | |
event = | |
IssueHasBeenPostedOnGithub.new(data: { payload: OpenStruct.new(message: "This is unpreserved OpenStruct.") }) | |
in_memory_repository_with_json_serialization_to_mimic_database_behaviour = | |
RubyEventStore::InMemoryRepository.new(serializer: JSON) | |
client = | |
RailsEventStore::JSONClient.new(repository: in_memory_repository_with_json_serialization_to_mimic_database_behaviour) | |
client.publish(event) | |
pp in_memory_repository_with_json_serialization_to_mimic_database_behaviour.storage | |
pp client.read.last |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment