Sha256: f107d12147170c9b715d3a4fe938710502db7f88cbebd9d3dac1b0fb92b47929

Contents?: true

Size: 708 Bytes

Versions: 20

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

module TableSync::Receiving
  module DSL
    def inherited(klass)
      klass.instance_variable_set(:@configs, configs.deep_dup)
      super
    end

    def configs
      @configs ||= Hash.new { |hash, key| hash[key] = [] }
    end

    def receive(source, to_table: nil, to_model: nil, events: [:update, :destroy], &block)
      model = to_table ? TableSync.receiving_model.new(to_table) : to_model

      TableSync::Utils::InterfaceChecker.new(model).implements(:receiving_model)

      config = ::TableSync::Receiving::Config.new(model: model, events: events)

      config.instance_exec(&block) if block

      configs[source.to_s] << config

      self
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
table_sync-6.5.1 lib/table_sync/receiving/dsl.rb
table_sync-6.5.0 lib/table_sync/receiving/dsl.rb
table_sync-6.4.2 lib/table_sync/receiving/dsl.rb
table_sync-6.4.1 lib/table_sync/receiving/dsl.rb
table_sync-6.4.0 lib/table_sync/receiving/dsl.rb
table_sync-6.3.0 lib/table_sync/receiving/dsl.rb
table_sync-6.1.0 lib/table_sync/receiving/dsl.rb
table_sync-6.0.4 lib/table_sync/receiving/dsl.rb
table_sync-6.0.3 lib/table_sync/receiving/dsl.rb
table_sync-6.0.2 lib/table_sync/receiving/dsl.rb
table_sync-6.0 lib/table_sync/receiving/dsl.rb
table_sync-5.1.0 lib/table_sync/receiving/dsl.rb
table_sync-5.0.0 lib/table_sync/receiving/dsl.rb
table_sync-4.2.2 lib/table_sync/receiving/dsl.rb
table_sync-4.2.1 lib/table_sync/receiving/dsl.rb
table_sync-4.2.0 lib/table_sync/receiving/dsl.rb
table_sync-4.1.3 lib/table_sync/receiving/dsl.rb
table_sync-4.1.1 lib/table_sync/receiving/dsl.rb
table_sync-4.1.0 lib/table_sync/receiving/dsl.rb
table_sync-4.0.0 lib/table_sync/receiving/dsl.rb