Sha256: f1e154af43f2e406cb43d6421cbab3554bb0241c1662b00753d331ac59b02e43

Contents?: true

Size: 900 Bytes

Versions: 6

Compression:

Stored size: 900 Bytes

Contents

# frozen_string_literal: true

module TableSync
  # rubocop:disable Style/MissingRespondToMissing, Style/MethodMissingSuper
  class ConfigDecorator
    include ::TableSync::EventActions
    extend Forwardable

    def_delegators :@config, :on_destroy, :wrap_receiving

    def initialize(config, handler)
      @config = config
      @handler = handler
    end

    def method_missing(name, *args)
      value = @config.send(name)

      if value.is_a?(Proc)
        value.call(
          event: @handler.event,
          model: @handler.model,
          version: @handler.version,
          project_id: @handler.project_id,
          data: @handler.data,
          current_row: args.first,
        )
      else
        value
      end
    end

    def allow_event?(event)
      @config.allow_event?(event)
    end
  end
  # rubocop:enable Style/MissingRespondToMissing, Style/MethodMissingSuper
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
table_sync-2.3.0 lib/table_sync/config_decorator.rb
table_sync-2.2.0 lib/table_sync/config_decorator.rb
table_sync-2.1.0 lib/table_sync/config_decorator.rb
table_sync-2.0.0 lib/table_sync/config_decorator.rb
table_sync-1.13.1 lib/table_sync/config_decorator.rb
table_sync-1.13.0 lib/table_sync/config_decorator.rb