lib/table_sync/publisher.rb in table_sync-1.8.0 vs lib/table_sync/publisher.rb in table_sync-1.9.0
- old
+ new
@@ -32,10 +32,12 @@
def publish_now
# Update request and object does not exist -> skip publishing
return if !object && !destroyed?
Rabbit.publish(params)
+ TableSync::Instrument.notify table: TableSync.orm.table_name(object_class),
+ event: event, direction: :publish
end
private
attr_reader :original_attributes
@@ -75,11 +77,11 @@
end
def publishing_data
{
**super,
- event: (destroyed? ? :destroy : :update),
+ event: event,
metadata: { created: created? },
}
end
def attributes_for_sync
@@ -96,9 +98,13 @@
end
end
memoize def object
TableSync.orm.find(object_class, needle)
+ end
+
+ def event
+ destroyed? ? :destroy : :update
end
def needle
original_attributes.slice(*primary_keys)
end