module TableSync::Receiving::DSL

Public Instance Methods

configs() click to toggle source
# File lib/table_sync/receiving/dsl.rb, line 10
def configs
  @configs ||= Hash.new { |hash, key| hash[key] = [] }
end
inherited(klass) click to toggle source
Calls superclass method
# File lib/table_sync/receiving/dsl.rb, line 5
def inherited(klass)
  klass.instance_variable_set(:@configs, configs.deep_dup)
  super
end
receive(source, to_table: nil, to_model: nil, events: [:update, :destroy], &block) click to toggle source
# File lib/table_sync/receiving/dsl.rb, line 14
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