Skip to content

Commit 7259cd0

Browse files
0expAS-AlStar
authored andcommitted
table-sync-custom-version
1 parent 29ce301 commit 7259cd0

7 files changed

Lines changed: 22 additions & 14 deletions

File tree

lib/table_sync/publishing/batch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class TableSync::Publishing::Batch
66

77
attribute :object_class
88
attribute :original_attributes
9-
9+
attribute :custom_version
1010
attribute :routing_key
1111
attribute :headers
1212

lib/table_sync/publishing/data/objects.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22

33
module TableSync::Publishing::Data
44
class Objects
5-
attr_reader :objects, :event
5+
attr_reader :objects, :event, :custom_version
66

7-
def initialize(objects:, event:)
8-
@objects = objects
9-
@event = TableSync::Event.new(event)
7+
def initialize(objects:, event:, custom_version:)
8+
@objects = objects
9+
@event = TableSync::Event.new(event)
10+
@custom_version = custom_version
1011
end
1112

1213
def construct
1314
{
1415
model: model,
1516
attributes: attributes_for_sync,
16-
version: version,
17+
version: custom_version || version,
1718
event: event.resolve,
1819
metadata: event.metadata,
1920
}

lib/table_sync/publishing/data/raw.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22

33
module TableSync::Publishing::Data
44
class Raw
5-
attr_reader :model_name, :attributes_for_sync, :event
5+
attr_reader :model_name, :attributes_for_sync, :event, :custom_version
66

7-
def initialize(model_name:, attributes_for_sync:, event:)
7+
def initialize(model_name:, attributes_for_sync:, event:, custom_version:)
88
@model_name = model_name
99
@attributes_for_sync = attributes_for_sync
1010
@event = TableSync::Event.new(event)
11+
@custom_version = custom_version
1112
end
1213

1314
def construct
1415
{
1516
model: model_name,
1617
attributes: wrapped_attributes_for_sync,
17-
version: version,
18+
version: custom_version || version,
1819
event: event.resolve,
1920
metadata: event.metadata,
2021
}

lib/table_sync/publishing/message/base.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Base
66

77
attr_reader :objects
88

9+
attribute :custom_version
910
attribute :object_class
1011
attribute :original_attributes
1112
attribute :event
@@ -44,7 +45,9 @@ def message_params
4445

4546
def data
4647
TableSync::Publishing::Data::Objects.new(
47-
objects: objects, event: event,
48+
objects: objects,
49+
event: event,
50+
custom_version: custom_version,
4851
).construct
4952
end
5053

lib/table_sync/publishing/message/raw.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Raw
1111

1212
attribute :routing_key
1313
attribute :headers
14-
14+
attribute :custom_version
1515
attribute :event
1616

1717
def publish
@@ -40,7 +40,10 @@ def message_params
4040

4141
def data
4242
TableSync::Publishing::Data::Raw.new(
43-
model_name: model_name, attributes_for_sync: original_attributes, event: event,
43+
model_name: model_name,
44+
attributes_for_sync: original_attributes,
45+
event: event,
46+
custom_version: custom_version,
4447
).construct
4548
end
4649

lib/table_sync/publishing/raw.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class TableSync::Publishing::Raw
88
attribute :table_name
99
attribute :schema_name
1010
attribute :original_attributes
11-
11+
attribute :custom_version
1212
attribute :routing_key
1313
attribute :headers
1414

lib/table_sync/publishing/single.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class TableSync::Publishing::Single
77
attribute :object_class
88
attribute :original_attributes
99
attribute :debounce_time
10-
10+
attribute :custom_version
1111
attribute :event, Symbol, default: :update
1212

1313
# expect job to have perform_at method

0 commit comments

Comments
 (0)