From ec1b5acf7b55e7af86ef60286041eea68fc7bda3 Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Thu, 4 Feb 2016 08:36:15 +0100 Subject: [PATCH 01/11] using sandthorn_driver_sequel with internal serialization --- Gemfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Gemfile b/Gemfile index e1b9d09..df0c0bf 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source 'https://rubygems.org' # Specify your gem's dependencies in sandthorn.gemspec gemspec +gem "sandthorn_driver_sequel", git: "https://github.com/Sandthorn/sandthorn_driver_sequel.git", branch: "move_serialization_to_driver" From a8e638f6fa1b05765e8f08b48822465308315494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Skarner?= Date: Thu, 4 Feb 2016 19:42:18 +0100 Subject: [PATCH 02/11] Remove the expectation of serialisation in Sandthorn This has moved to the driver instead. --- lib/sandthorn/aggregate_root_base.rb | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/sandthorn/aggregate_root_base.rb b/lib/sandthorn/aggregate_root_base.rb index 1e5399c..94f50bc 100644 --- a/lib/sandthorn/aggregate_root_base.rb +++ b/lib/sandthorn/aggregate_root_base.rb @@ -19,12 +19,7 @@ def aggregate_base_initialize end def save - aggregate_events.each do |event| - event[:event_data] = Sandthorn.serialize event[:event_args] - event[:event_args] = nil #Not send extra data over the wire - end - - unless aggregate_events.empty? + if aggregate_events.any? Sandthorn.save_events( aggregate_events, aggregate_id, @@ -90,26 +85,22 @@ def aggregate_find aggregate_id unless events && !events.empty? raise Sandthorn::Errors::AggregateNotFound end - + if first_event_snapshot?(events) transformed_snapshot_event = events.first.merge(event_args: Sandthorn.deserialize_snapshot(events.first[:event_data])) events.shift end - transformed_events = events.map do |e| - e.merge(event_args: Sandthorn.deserialize(e[:event_data])) - end - aggregate_build ([transformed_snapshot_event] + transformed_events).compact + aggregate_build ([transformed_snapshot_event] + events).compact end def new *args, &block - aggregate = allocate aggregate.aggregate_base_initialize aggregate.aggregate_initialize aggregate.default_attributes - aggregate.send :initialize, *args, &block + aggregate.send :initialize, *args, &block aggregate.send :set_aggregate_id, Sandthorn.generate_aggregate_id aggregate.aggregate_trace @@aggregate_trace_information do |aggr| @@ -139,7 +130,7 @@ def aggregate_build events aggregate.send :set_orginating_aggregate_version!, current_aggregate_version aggregate.send :set_current_aggregate_version!, current_aggregate_version aggregate.send :aggregate_initialize - + aggregate.send :set_instance_variables!, attributes aggregate end From 1cde2235cde1358bec91579b89ea7ea2e100aae6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Skarner?= Date: Thu, 4 Feb 2016 20:11:45 +0100 Subject: [PATCH 03/11] Clean out remaining serialize and deserialize from sandthorn this included making some small changes in the spec_helper as well where the driver is defined and Sandthorn configured. --- lib/sandthorn.rb | 35 ----------------------------------- spec/spec_helper.rb | 11 +++++++---- 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/lib/sandthorn.rb b/lib/sandthorn.rb index 303555e..c2823ac 100644 --- a/lib/sandthorn.rb +++ b/lib/sandthorn.rb @@ -62,8 +62,6 @@ def get_events event_store: :default, aggregate_types: [], take: 0, after_sequen event_store = find_event_store(event_store) events = event_store.get_events aggregate_types: aggregate_types, take: take, after_sequence_number: after_sequence_number events.map do |event| - event[:event_args] = deserialize event[:event_data] - event.delete(:event_data) Event.new(event) end end @@ -111,38 +109,6 @@ def event_store=(store) @event_stores = EventStores.new(store) end - def serializer=(block) - @serializer = block if block.is_a? Proc - end - - def deserializer=(block) - @deserializer = block if block.is_a? Proc - end - - def serializer - @serializer || default_serializer - end - - def deserializer - @deserializer || default_deserializer - end - - def default_serializer - -> (data) { YAML.dump(data) } - end - - def default_deserializer - -> (data) { YAML.load(data) } - end - - def serialize(data) - serializer.call(data) - end - - def deserialize(data) - deserializer.call(data) - end - def snapshot_serializer=(block) @snapshot_serializer = block if block.is_a? Proc end @@ -171,7 +137,6 @@ def map_types= data @event_stores.map_types data end - alias_method :event_stores=, :event_store= end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c216448..8c84e41 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -40,12 +40,15 @@ def spec_db "sqlite://spec/db/sequel_driver.sqlite3" end def sqlite_store_setup - url = spec_db - driver = SandthornDriverSequel.driver_from_url(url: url) + url = spec_db + + driver = SandthornDriverSequel.driver_from_url(url: url) do |driver| + driver.event_serializer = Proc.new { |data| YAML::dump(data) } + driver.event_deserializer = Proc.new { |data| YAML::load(data) } + end + Sandthorn.configure do |c| c.event_store = driver - c.serializer = Proc.new { |data| YAML::dump(data) } - c.deserializer = Proc.new { |data| YAML::load(data) } c.snapshot_serializer = Proc.new { |data| YAML::dump(data) } c.snapshot_deserializer = Proc.new { |data| YAML::load(data) } end From ae9da0b59540a6854c30fe2df271eb74ff767642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Skarner?= Date: Thu, 4 Feb 2016 20:13:08 +0100 Subject: [PATCH 04/11] Clean up warnings in the specs from using `raise_error` --- spec/aggregate_root_spec.rb | 8 ++++---- spec/aggregate_snapshot_spec.rb | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/aggregate_root_spec.rb b/spec/aggregate_root_spec.rb index 9e3efac..7506676 100644 --- a/spec/aggregate_root_spec.rb +++ b/spec/aggregate_root_spec.rb @@ -87,7 +87,7 @@ def no_state_change_only_empty_event it "should set the values" do expect(subject.name).to eql "Mogge" expect(subject.sex).to eql "hen" - expect{subject.writer}.to raise_error + expect{subject.writer}.to raise_error NoMethodError end end @@ -117,12 +117,12 @@ def no_state_change_only_empty_event context "when changing writer (attr_writer)" do it "should raise error" do - expect{dirty_object.change_writer "new_writer"}.to raise_error + expect{dirty_object.change_writer "new_writer"}.to raise_error NameError end end context "save" do - it "should not have events on aggregete after save" do + it "should not have events on aggregate after save" do expect(dirty_object.save.aggregate_events.length).to eql 0 end @@ -147,7 +147,7 @@ def no_state_change_only_empty_event end it "should raise error if trying to find id that not exist" do - expect{DirtyClass.find("666")}.to raise_error + expect{DirtyClass.find("666")}.to raise_error NoMethodError end end diff --git a/spec/aggregate_snapshot_spec.rb b/spec/aggregate_snapshot_spec.rb index 5f7e438..ebcdee3 100644 --- a/spec/aggregate_snapshot_spec.rb +++ b/spec/aggregate_snapshot_spec.rb @@ -243,7 +243,7 @@ def a_test_account end it 'should raise error if trying to create snapshot before events are saved on object' do - expect(lambda {account.aggregate_snapshot!}).to raise_error + expect(lambda {account.aggregate_snapshot!}).to raise_error Sandthorn::Errors::SnapshotError end it 'should not raise an error if trying to create snapshot on object when events are saved' do From 999fa269181559e09774ebf008bcd7fd219ae26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Skarner?= Date: Thu, 4 Feb 2016 20:56:13 +0100 Subject: [PATCH 05/11] Remove `aggregate_create_event_when_extended` not used --- lib/sandthorn/aggregate_root_snapshot.rb | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/lib/sandthorn/aggregate_root_snapshot.rb b/lib/sandthorn/aggregate_root_snapshot.rb index e315b74..18c1540 100644 --- a/lib/sandthorn/aggregate_root_snapshot.rb +++ b/lib/sandthorn/aggregate_root_snapshot.rb @@ -30,22 +30,5 @@ def save_snapshot Sandthorn.save_snapshot(aggregate_snapshot: @aggregate_snapshot, aggregate_id: @aggregate_id, aggregate_type: self.class) @aggregate_snapshot = nil end - private - def aggregate_create_event_when_extended - self.aggregate_snapshot! - vars = extract_relevant_aggregate_instance_variables - vars.each do |var_name| - value = instance_variable_get var_name - dump = Marshal.dump(value) - store_aggregate_instance_variable var_name, dump - end - - @aggregate_snapshot[:event_data] = Sandthorn - .serialize_snapshot aggregate_snapshot[:event_args] - - @aggregate_snapshot[:event_args] = nil - Sandthorn.save_snapshot aggregate_snapshot, aggregate_id - @aggregate_snapshot = nil - end end end From ae6bdf9836123fe101334d6233466a72e5995ba7 Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Mon, 8 Feb 2016 22:49:55 +0100 Subject: [PATCH 06/11] Update README.md Documentation of the moved serialization to the driver. --- README.md | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index ae4bc28..2ad787d 100644 --- a/README.md +++ b/README.md @@ -182,19 +182,34 @@ Sandthorn.configure do |conf| end ``` -## Data serialization / deserialization +## Data serialization -Its possible to configure how events and snapshots are serialized / deserialized. The default are YAML but can be overloaded in the configure block. +Its possible to configure how events and snapshots are serialized. The default are YAML but can be overloaded ~~in the configure block~~. + +Since version 0.11.0 of Sandthorn the serialization of events and snapshots are moved to the drivers. Its possible to have different serialization algorithms / driver. ```ruby -Sandthorn.configure do |conf| - conf.serializer = Proc.new { |data| Oj::dump(data) } - conf.deserializer = Proc.new { |data| Oj::load(data) } - conf.snapshot_serializer = Proc.new { |data| Oj::dump(data) } - conf.snapshot_deserializer = Proc.new { |data| Oj::load(data) } -end +oj_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) { |conf| + conf.event_serializer = Proc.new { |data| Oj::dump(data) } + conf.event_deserializer = Proc.new { |data| Oj::load(data) } +} ``` +Will generate a driver that uses the Oj gem for event serialization. +```ruby +#Gets the default YAML serializer +yaml_serializer_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) + +#Change the global configuration +SandthornDriverSequel.configure { |conf| + conf.event_serializer = Proc.new { |data| Oj::dump(data) } + conf.event_deserializer = Proc.new { |data| Oj::load(data) } +} + +#Gets the Oj serializer +oj_serializer_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) +``` +Changes the global configuration of the `SandthornDriverSequel` driver. # Usage From 796e272b0b8faffe7a5b704e16606b6eab463ffe Mon Sep 17 00:00:00 2001 From: Jesper Josefsson Date: Tue, 9 Feb 2016 14:50:07 +0100 Subject: [PATCH 07/11] Simplify docs about serialization --- README.md | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 2ad787d..831b83c 100644 --- a/README.md +++ b/README.md @@ -184,32 +184,18 @@ end ## Data serialization -Its possible to configure how events and snapshots are serialized. The default are YAML but can be overloaded ~~in the configure block~~. +Its possible to configure how events and snapshots are serialized. Since version `0.11.0` of Sandthorn the serialization of events and snapshots is the responsibility of the driver. This means drivers can have different serialization mechanism, independent of each other. -Since version 0.11.0 of Sandthorn the serialization of events and snapshots are moved to the drivers. Its possible to have different serialization algorithms / driver. +The default serializer of the Sequel driver is YAML. -```ruby -oj_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) { |conf| - conf.event_serializer = Proc.new { |data| Oj::dump(data) } - conf.event_deserializer = Proc.new { |data| Oj::load(data) } -} -``` -Will generate a driver that uses the Oj gem for event serialization. +Here's how to use the Oj gem to serialize data in the Sequel driver: ```ruby -#Gets the default YAML serializer -yaml_serializer_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) - -#Change the global configuration -SandthornDriverSequel.configure { |conf| +oj_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) { |conf| conf.event_serializer = Proc.new { |data| Oj::dump(data) } conf.event_deserializer = Proc.new { |data| Oj::load(data) } } - -#Gets the Oj serializer -oj_serializer_driver = SandthornDriverSequel.driver_from_connection(connection: Sequel.sqlite) ``` -Changes the global configuration of the `SandthornDriverSequel` driver. # Usage From 75eec47b8f5a49be30412b5cbe9fc7592472b0e3 Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Tue, 9 Feb 2016 21:42:57 +0100 Subject: [PATCH 08/11] implemented the snapshot changes made in the driver and some refactoring --- lib/sandthorn.rb | 36 ++---------------------- lib/sandthorn/aggregate_root_base.rb | 29 ++++++++----------- lib/sandthorn/aggregate_root_snapshot.rb | 14 +-------- sandthorn.gemspec | 2 +- spec/aggregate_root_spec.rb | 2 +- spec/aggregate_snapshot_spec.rb | 13 ++------- spec/spec_helper.rb | 12 ++++---- 7 files changed, 26 insertions(+), 82 deletions(-) diff --git a/lib/sandthorn.rb b/lib/sandthorn.rb index c2823ac..b736824 100644 --- a/lib/sandthorn.rb +++ b/lib/sandthorn.rb @@ -10,7 +10,7 @@ module Sandthorn class << self extend Forwardable - def_delegators :configuration, :event_stores, :serialize, :deserialize, :serialize_snapshot, :deserialize_snapshot + def_delegators :configuration, :event_stores def default_event_store event_stores.default_store @@ -28,8 +28,6 @@ def configuration @configuration ||= Configuration.new end - - def generate_aggregate_id SecureRandom.uuid end @@ -46,12 +44,8 @@ def get_aggregate aggregate_id, aggregate_type event_store_for(aggregate_type).get_aggregate_events_from_snapshot aggregate_id end - def save_snapshot( - aggregate_type: missing_key(:aggregate_type), - aggregate_snapshot: missing_key(:aggregate_snapshot), - aggregate_id: missing_key(:aggregate_id) - ) - event_store_for(aggregate_type).save_snapshot(aggregate_snapshot, aggregate_id) + def save_snapshot(aggregate) + event_store_for(aggregate.class).save_snapshot(aggregate) end def get_aggregate_list_by_type aggregate_type @@ -109,30 +103,6 @@ def event_store=(store) @event_stores = EventStores.new(store) end - def snapshot_serializer=(block) - @snapshot_serializer = block if block.is_a? Proc - end - - def snapshot_deserializer=(block) - @snapshot_deserializer = block if block.is_a? Proc - end - - def snapshot_serializer - @snapshot_serializer || default_serializer - end - - def snapshot_deserializer - @snapshot_deserializer || default_deserializer - end - - def serialize_snapshot(data) - snapshot_serializer.call(data) - end - - def deserialize_snapshot data - snapshot_deserializer.call(data) - end - def map_types= data @event_stores.map_types data end diff --git a/lib/sandthorn/aggregate_root_base.rb b/lib/sandthorn/aggregate_root_base.rb index 94f50bc..970be60 100644 --- a/lib/sandthorn/aggregate_root_base.rb +++ b/lib/sandthorn/aggregate_root_base.rb @@ -10,6 +10,7 @@ module Base attr_reader :aggregate_trace_information alias :id :aggregate_id + alias :aggregate_version :aggregate_current_event_version def aggregate_base_initialize @@ -86,12 +87,7 @@ def aggregate_find aggregate_id raise Sandthorn::Errors::AggregateNotFound end - if first_event_snapshot?(events) - transformed_snapshot_event = events.first.merge(event_args: Sandthorn.deserialize_snapshot(events.first[:event_data])) - events.shift - end - - aggregate_build ([transformed_snapshot_event] + events).compact + aggregate_build events end def new *args, &block @@ -110,25 +106,26 @@ def new *args, &block end - - def aggregate_build events current_aggregate_version = 0 if first_event_snapshot?(events) - aggregate = start_build_from_snapshot events - current_aggregate_version = aggregate.aggregate_originating_version + aggregate = events.first[:aggregate] events.shift else aggregate = create_new_empty_aggregate end + if events.any? + current_aggregate_version = events.last[:aggregate_version] + aggregate.send :set_orginating_aggregate_version!, current_aggregate_version + aggregate.send :set_current_aggregate_version!, current_aggregate_version + end + attributes = build_instance_vars_from_events events - current_aggregate_version = events.last[:aggregate_version] unless events.empty? aggregate.send :clear_aggregate_events + aggregate.default_attributes - aggregate.send :set_orginating_aggregate_version!, current_aggregate_version - aggregate.send :set_current_aggregate_version!, current_aggregate_version aggregate.send :aggregate_initialize aggregate.send :set_instance_variables!, attributes @@ -162,11 +159,7 @@ def build_instance_vars_from_events events end def first_event_snapshot? events - events.first[:event_name].to_sym == :aggregate_set_from_snapshot - end - - def start_build_from_snapshot events - snapshot = events.first[:event_args][0] + events.first[:aggregate] end def create_new_empty_aggregate diff --git a/lib/sandthorn/aggregate_root_snapshot.rb b/lib/sandthorn/aggregate_root_snapshot.rb index 18c1540..d522c47 100644 --- a/lib/sandthorn/aggregate_root_snapshot.rb +++ b/lib/sandthorn/aggregate_root_snapshot.rb @@ -13,22 +13,10 @@ def aggregate_snapshot! raise Errors::SnapshotError, "Can't take snapshot on object with unsaved events" end - - @aggregate_snapshot = { - event_name: "aggregate_set_from_snapshot", - event_args: [self], - aggregate_version: @aggregate_current_event_version - } end def save_snapshot - unless aggregate_snapshot - raise Errors::SnapshotError, "No snapshot has been created!" - end - @aggregate_snapshot[:event_data] = Sandthorn.serialize_snapshot @aggregate_snapshot[:event_args] - @aggregate_snapshot[:event_args] = nil - Sandthorn.save_snapshot(aggregate_snapshot: @aggregate_snapshot, aggregate_id: @aggregate_id, aggregate_type: self.class) - @aggregate_snapshot = nil + Sandthorn.save_snapshot(self) end end end diff --git a/sandthorn.gemspec b/sandthorn.gemspec index 39899e0..dcd71a0 100644 --- a/sandthorn.gemspec +++ b/sandthorn.gemspec @@ -30,5 +30,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "autotest-standalone" spec.add_development_dependency "sqlite3" spec.add_development_dependency "coveralls" - spec.add_development_dependency "sandthorn_driver_sequel", "~> 2.0" + #spec.add_development_dependency "sandthorn_driver_sequel", "~> 2.0" end diff --git a/spec/aggregate_root_spec.rb b/spec/aggregate_root_spec.rb index 7506676..0835442 100644 --- a/spec/aggregate_root_spec.rb +++ b/spec/aggregate_root_spec.rb @@ -147,7 +147,7 @@ def no_state_change_only_empty_event end it "should raise error if trying to find id that not exist" do - expect{DirtyClass.find("666")}.to raise_error NoMethodError + expect{DirtyClass.find("666")}.to raise_error Sandthorn::Errors::AggregateNotFound end end diff --git a/spec/aggregate_snapshot_spec.rb b/spec/aggregate_snapshot_spec.rb index ebcdee3..27b4376 100644 --- a/spec/aggregate_snapshot_spec.rb +++ b/spec/aggregate_snapshot_spec.rb @@ -185,17 +185,10 @@ def a_test_account expect(@account.unpaid_interest_balance).to be > 1000 end - it 'should store snapshot data in aggregate_snapshot' do - expect(@account.aggregate_snapshot).to be_a(Hash) - end - - it 'should store aggregate_version in aggregate_snapshot' do - expect(@account.aggregate_snapshot[:aggregate_version]).to eql(@original_account.aggregate_current_event_version) - end it 'should be able to load up from snapshot' do - events = [@account.aggregate_snapshot] + events = [aggregate: @account] loaded = BankAccount.aggregate_build events expect(loaded.balance).to eql(@original_account.balance) @@ -227,9 +220,7 @@ def a_test_account describe 'when saving to repository' do let(:account) {a_test_account.extend Sandthorn::AggregateRootSnapshot} - it 'should raise an error if trying to save before creating a snapshot' do - expect(lambda {account.save_snapshot}).to raise_error (Sandthorn::Errors::SnapshotError) - end + it 'should not raise an error if snapshot was created' do account.save account.aggregate_snapshot! diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8c84e41..cf15495 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -42,15 +42,17 @@ def spec_db def sqlite_store_setup url = spec_db - driver = SandthornDriverSequel.driver_from_url(url: url) do |driver| - driver.event_serializer = Proc.new { |data| YAML::dump(data) } - driver.event_deserializer = Proc.new { |data| YAML::load(data) } + driver = SandthornDriverSequel.driver_from_url(url: url) do |conf| + conf.event_serializer = Proc.new { |data| YAML::dump(data) } + conf.event_deserializer = Proc.new { |data| YAML::load(data) } + conf.snapshot_serializer = Proc.new { |data| YAML::dump(data) } + conf.snapshot_deserializer = Proc.new { |data| YAML::load(data) } end Sandthorn.configure do |c| c.event_store = driver - c.snapshot_serializer = Proc.new { |data| YAML::dump(data) } - c.snapshot_deserializer = Proc.new { |data| YAML::load(data) } + #c.snapshot_serializer = Proc.new { |data| YAML::dump(data) } + #c.snapshot_deserializer = Proc.new { |data| YAML::load(data) } end migrator = SandthornDriverSequel::Migration.new url: url SandthornDriverSequel.migrate_db url: url From 4862e3969d549b7fb91d77f9280603962658150b Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Tue, 9 Feb 2016 21:53:06 +0100 Subject: [PATCH 09/11] refactoring and remomved unused code --- lib/sandthorn/aggregate_root_base.rb | 5 +---- spec/spec_helper.rb | 2 -- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/sandthorn/aggregate_root_base.rb b/lib/sandthorn/aggregate_root_base.rb index 970be60..8977831 100644 --- a/lib/sandthorn/aggregate_root_base.rb +++ b/lib/sandthorn/aggregate_root_base.rb @@ -91,7 +91,7 @@ def aggregate_find aggregate_id end def new *args, &block - aggregate = allocate + aggregate = create_new_empty_aggregate() aggregate.aggregate_base_initialize aggregate.aggregate_initialize @@ -107,8 +107,6 @@ def new *args, &block end def aggregate_build events - current_aggregate_version = 0 - if first_event_snapshot?(events) aggregate = events.first[:aggregate] events.shift @@ -147,7 +145,6 @@ def events(*event_names) def build_instance_vars_from_events events events.each_with_object({}) do |event, instance_vars| event_args = event[:event_args] - event_name = event[:event_name] attribute_deltas = event_args[:attribute_deltas] unless attribute_deltas.nil? deltas = attribute_deltas.each_with_object({}) do |delta, acc| diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index cf15495..6c351b9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -51,8 +51,6 @@ def sqlite_store_setup Sandthorn.configure do |c| c.event_store = driver - #c.snapshot_serializer = Proc.new { |data| YAML::dump(data) } - #c.snapshot_deserializer = Proc.new { |data| YAML::load(data) } end migrator = SandthornDriverSequel::Migration.new url: url SandthornDriverSequel.migrate_db url: url From d07f52155d99317868ee59486d5a8b0d6b580b4b Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Thu, 11 Feb 2016 20:07:10 +0100 Subject: [PATCH 10/11] depend on sandthorn_driver_sequel 3.0.0 in specs --- Gemfile | 3 +-- sandthorn.gemspec | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index df0c0bf..b993713 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,4 @@ source 'https://rubygems.org' # Specify your gem's dependencies in sandthorn.gemspec -gemspec -gem "sandthorn_driver_sequel", git: "https://github.com/Sandthorn/sandthorn_driver_sequel.git", branch: "move_serialization_to_driver" +gemspec \ No newline at end of file diff --git a/sandthorn.gemspec b/sandthorn.gemspec index dcd71a0..4e1ed78 100644 --- a/sandthorn.gemspec +++ b/sandthorn.gemspec @@ -30,5 +30,5 @@ Gem::Specification.new do |spec| spec.add_development_dependency "autotest-standalone" spec.add_development_dependency "sqlite3" spec.add_development_dependency "coveralls" - #spec.add_development_dependency "sandthorn_driver_sequel", "~> 2.0" + spec.add_development_dependency "sandthorn_driver_sequel", ">= 3.0" end From 85a75430f3e1c6524ff51faff667e8aeede36914 Mon Sep 17 00:00:00 2001 From: Morgan Hallgren Date: Thu, 11 Feb 2016 20:07:30 +0100 Subject: [PATCH 11/11] Bump to 0.11.0 --- lib/sandthorn/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sandthorn/version.rb b/lib/sandthorn/version.rb index dd5d433..d1b0de2 100644 --- a/lib/sandthorn/version.rb +++ b/lib/sandthorn/version.rb @@ -1,3 +1,3 @@ module Sandthorn - VERSION = "0.10.3" + VERSION = "0.11.0" end