Skip to content

Instantly share code, notes, and snippets.

@mostlyobvious
Created June 17, 2023 09:59
Show Gist options
  • Save mostlyobvious/75ff4ee755777b4ce6d7879d811bcfb2 to your computer and use it in GitHub Desktop.
Save mostlyobvious/75ff4ee755777b4ce6d7879d811bcfb2 to your computer and use it in GitHub Desktop.
#!/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