Skip to content

Commit f4506e4

Browse files
committed
table-sync-custom-version
1 parent 9a50712 commit f4506e4

File tree

7 files changed

+22
-14
lines changed

7 files changed

+22
-14
lines changed

lib/table_sync/publishing/batch.rb

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

66
attribute :object_class
77
attribute :original_attributes
8-
8+
attribute :custom_version
99
attribute :routing_key
1010
attribute :headers
1111

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 :object_class, :attributes_for_sync, :event
5+
attr_reader :object_class, :attributes_for_sync, :event, :custom_version
66

7-
def initialize(object_class:, attributes_for_sync:, event:)
7+
def initialize(object_class:, attributes_for_sync:, event:, custom_version:)
88
@object_class = object_class
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: object_class,
1617
attributes: 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
@@ -8,7 +8,7 @@ class Raw
88
attribute :original_attributes
99
attribute :routing_key
1010
attribute :headers
11-
11+
attribute :custom_version
1212
attribute :event
1313

1414
def publish
@@ -41,7 +41,10 @@ def message_params
4141

4242
def data
4343
TableSync::Publishing::Data::Raw.new(
44-
object_class: object_class, attributes_for_sync: original_attributes, event: event,
44+
object_class: object_class,
45+
attributes_for_sync: original_attributes,
46+
event: event,
47+
custom_version: custom_version,
4548
).construct
4649
end
4750

lib/table_sync/publishing/raw.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TableSync::Publishing::Raw
55

66
attribute :object_class
77
attribute :original_attributes
8-
8+
attribute :custom_version
99
attribute :routing_key
1010
attribute :headers
1111

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)