Sha256: 8d5fb4cf69ed26081a6a3e13ab766c87c6b716d2a38ba766094e237eee27f083

Contents?: true

Size: 617 Bytes

Versions: 3

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

3 entries across 3 versions & 1 rubygems

Version Path
table_sync-6.0.4 lib/table_sync/setup/active_record.rb
table_sync-6.0.3 lib/table_sync/setup/active_record.rb
table_sync-6.0.2 lib/table_sync/setup/active_record.rb