Sha256: 66b12eea3a65dd3acf7e6b8aa88fa1d783ae4533a7f0dbe18eaf2b8688d9e79b

Contents?: true

Size: 1.32 KB

Versions: 11

Compression:

Stored size: 1.32 KB

Contents

# frozen_string_literal: true

module TableSync::Publishing::Params
  class Base
    DEFAULT_PARAMS = {
      confirm_select: true,
      realtime: true,
      event: :table_sync,
    }.freeze

    def construct
      DEFAULT_PARAMS.merge(
        routing_key: routing_key,
        headers: headers,
        exchange_name: exchange_name,
      )
    end

    private

    def calculated_routing_key
      if TableSync.routing_key_callable
        TableSync.routing_key_callable.call(object_class, attributes_for_routing_key)
      else
        raise TableSync::NoCallableError.new("routing_key")
      end
    end

    def calculated_headers
      if TableSync.headers_callable
        TableSync.headers_callable.call(object_class, attributes_for_headers)
      else
        raise TableSync::NoCallableError.new("headers")
      end
    end

    # NOT IMPLEMENTED

    # name of the model being synced in the string format
    # :nocov:
    def object_class
      raise NotImplementedError
    end

    def routing_key
      raise NotImplementedError
    end

    def headers
      raise NotImplementedError
    end

    def exchange_name
      raise NotImplementedError
    end

    def attributes_for_routing_key
      raise NotImplementedError
    end

    def attributes_for_headers
      raise NotImplementedError
    end
    # :nocov:
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
table_sync-6.5.1 lib/table_sync/publishing/params/base.rb
table_sync-6.5.0 lib/table_sync/publishing/params/base.rb
table_sync-6.4.2 lib/table_sync/publishing/params/base.rb
table_sync-6.4.1 lib/table_sync/publishing/params/base.rb
table_sync-6.4.0 lib/table_sync/publishing/params/base.rb
table_sync-6.3.0 lib/table_sync/publishing/params/base.rb
table_sync-6.1.0 lib/table_sync/publishing/params/base.rb
table_sync-6.0.4 lib/table_sync/publishing/params/base.rb
table_sync-6.0.3 lib/table_sync/publishing/params/base.rb
table_sync-6.0.2 lib/table_sync/publishing/params/base.rb
table_sync-6.0 lib/table_sync/publishing/params/base.rb