lib/table_sync/config.rb in table_sync-1.5.0 vs lib/table_sync/config.rb in table_sync-1.6.0
- old
+ new
@@ -15,10 +15,11 @@
additional_data({})
default_values({})
@rest_key = :rest
@version_key = :version
@first_sync_time_key = nil
+ @on_destroy = nil
target_keys(model.primary_keys)
end
# add_option implements next logic
# config.option - get value
@@ -51,9 +52,13 @@
callback_registry.register_callback(block, kind: :before_commit, event: on.to_sym)
end
def after_commit(on:, &block)
callback_registry.register_callback(block, kind: :after_commit, event: on.to_sym)
+ end
+
+ def on_destroy(&block)
+ block_given? ? @on_destroy = block : @on_destroy
end
check_and_set_column_key = proc do |key|
key = key.to_sym
raise "#{model.inspect} doesn't have key: #{key}" unless model.columns.include?(key)