diff --git a/lib/table_sync/publishing/batch.rb b/lib/table_sync/publishing/batch.rb index e67ee1c..49cba52 100644 --- a/lib/table_sync/publishing/batch.rb +++ b/lib/table_sync/publishing/batch.rb @@ -5,7 +5,7 @@ class TableSync::Publishing::Batch attribute :object_class attribute :original_attributes - + attribute :custom_version attribute :routing_key attribute :headers diff --git a/lib/table_sync/publishing/data/objects.rb b/lib/table_sync/publishing/data/objects.rb index f1ab5e3..058638a 100644 --- a/lib/table_sync/publishing/data/objects.rb +++ b/lib/table_sync/publishing/data/objects.rb @@ -2,18 +2,19 @@ module TableSync::Publishing::Data class Objects - attr_reader :objects, :event + attr_reader :objects, :event, :custom_version - def initialize(objects:, event:) - @objects = objects - @event = TableSync::Event.new(event) + def initialize(objects:, event:, custom_version:) + @objects = objects + @event = TableSync::Event.new(event) + @custom_version = custom_version end def construct { model: model, attributes: attributes_for_sync, - version: version, + version: custom_version || version, event: event.resolve, metadata: event.metadata, } diff --git a/lib/table_sync/publishing/data/raw.rb b/lib/table_sync/publishing/data/raw.rb index e52de81..27fa555 100644 --- a/lib/table_sync/publishing/data/raw.rb +++ b/lib/table_sync/publishing/data/raw.rb @@ -2,19 +2,20 @@ module TableSync::Publishing::Data class Raw - attr_reader :object_class, :attributes_for_sync, :event + attr_reader :object_class, :attributes_for_sync, :event, :custom_version - def initialize(object_class:, attributes_for_sync:, event:) + def initialize(object_class:, attributes_for_sync:, event:, custom_version:) @object_class = object_class @attributes_for_sync = attributes_for_sync @event = TableSync::Event.new(event) + @custom_version = custom_version end def construct { model: object_class, attributes: attributes_for_sync, - version: version, + version: custom_version || version, event: event.resolve, metadata: event.metadata, } diff --git a/lib/table_sync/publishing/message/base.rb b/lib/table_sync/publishing/message/base.rb index a2af8bc..94305b5 100644 --- a/lib/table_sync/publishing/message/base.rb +++ b/lib/table_sync/publishing/message/base.rb @@ -6,6 +6,7 @@ class Base attr_reader :objects + attribute :custom_version attribute :object_class attribute :original_attributes attribute :event @@ -44,7 +45,9 @@ def message_params def data TableSync::Publishing::Data::Objects.new( - objects: objects, event: event, + objects: objects, + event: event, + custom_version: custom_version, ).construct end diff --git a/lib/table_sync/publishing/message/raw.rb b/lib/table_sync/publishing/message/raw.rb index 2fc10ef..000fe27 100644 --- a/lib/table_sync/publishing/message/raw.rb +++ b/lib/table_sync/publishing/message/raw.rb @@ -8,7 +8,7 @@ class Raw attribute :original_attributes attribute :routing_key attribute :headers - + attribute :custom_version attribute :event def publish @@ -41,7 +41,10 @@ def message_params def data TableSync::Publishing::Data::Raw.new( - object_class: object_class, attributes_for_sync: original_attributes, event: event, + object_class: object_class, + attributes_for_sync: original_attributes, + event: event, + custom_version: custom_version, ).construct end diff --git a/lib/table_sync/publishing/raw.rb b/lib/table_sync/publishing/raw.rb index 6e1fa0f..8f3110b 100644 --- a/lib/table_sync/publishing/raw.rb +++ b/lib/table_sync/publishing/raw.rb @@ -5,7 +5,7 @@ class TableSync::Publishing::Raw attribute :object_class attribute :original_attributes - + attribute :custom_version attribute :routing_key attribute :headers diff --git a/lib/table_sync/publishing/single.rb b/lib/table_sync/publishing/single.rb index 063b6fa..b46ba57 100644 --- a/lib/table_sync/publishing/single.rb +++ b/lib/table_sync/publishing/single.rb @@ -7,7 +7,7 @@ class TableSync::Publishing::Single attribute :object_class attribute :original_attributes attribute :debounce_time - + attribute :custom_version attribute :event, Symbol, default: :update # expect job to have perform_at method