Sha256: 2d8c48d1c0e5cdc1758f8b32102758cc4eb4c65deea0dca9e8669789b8db32ff

Contents?: true

Size: 617 Bytes

Versions: 7

Compression:

Stored size: 617 Bytes

Contents

# frozen_string_literal: true

module TableSync::Setup
  class ActiveRecord < Base
    private

    def define_after_commit(event)
      options = options_exposed_for_block

      object_class.after_commit(on: event) do
        next if new_record? && destroyed?

        if instance_eval(&options[:if]) && !instance_eval(&options[:unless])
          TableSync::Publishing::Single.new(
            object_class: self.class.name,
            original_attributes: attributes,
            event: event,
            debounce_time: options[:debounce_time],
          ).publish_later
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
table_sync-6.5.1 lib/table_sync/setup/active_record.rb
table_sync-6.5.0 lib/table_sync/setup/active_record.rb
table_sync-6.4.2 lib/table_sync/setup/active_record.rb
table_sync-6.4.1 lib/table_sync/setup/active_record.rb
table_sync-6.4.0 lib/table_sync/setup/active_record.rb
table_sync-6.3.0 lib/table_sync/setup/active_record.rb
table_sync-6.1.0 lib/table_sync/setup/active_record.rb