Skip to content

Commit

Permalink
table-sync-custom-version
Browse files Browse the repository at this point in the history
  • Loading branch information
0exp committed Sep 2, 2024
1 parent 9a50712 commit f4506e4
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/table_sync/publishing/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TableSync::Publishing::Batch

attribute :object_class
attribute :original_attributes

attribute :custom_version
attribute :routing_key
attribute :headers

Expand Down
11 changes: 6 additions & 5 deletions lib/table_sync/publishing/data/objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
7 changes: 4 additions & 3 deletions lib/table_sync/publishing/data/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
5 changes: 4 additions & 1 deletion lib/table_sync/publishing/message/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class Base

attr_reader :objects

attribute :custom_version
attribute :object_class
attribute :original_attributes
attribute :event
Expand Down Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/table_sync/publishing/message/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Raw
attribute :original_attributes
attribute :routing_key
attribute :headers

attribute :custom_version
attribute :event

def publish
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion lib/table_sync/publishing/raw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TableSync::Publishing::Raw

attribute :object_class
attribute :original_attributes

attribute :custom_version
attribute :routing_key
attribute :headers

Expand Down
2 changes: 1 addition & 1 deletion lib/table_sync/publishing/single.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f4506e4

Please sign in to comment.