class HubLink::Importer

Attributes

repo[R]
resources[R]
since[R]

Public Class Methods

new(repo:, since:, resources:) click to toggle source
# File lib/hub_link/importer.rb, line 9
def initialize(repo:, since:, resources:)
  @repo = repo.to_s
  @since = since
  @resources = resources
end
run(*args) click to toggle source
# File lib/hub_link/importer.rb, line 5
def self.run(*args)
  new(*args).run
end

Public Instance Methods

run() click to toggle source
# File lib/hub_link/importer.rb, line 15
def run
  stream.in_batches do |batch|
    resources.each do |source, target|
      import batch.fetch(source), to: target
    end
  end
end

Private Instance Methods

import(records, to:) click to toggle source
# File lib/hub_link/importer.rb, line 31
def import(records, to:)
  records.each do |row|
    Insert.new(row: row, target: to).run
  end
end
stream() click to toggle source
# File lib/hub_link/importer.rb, line 27
def stream
  @_stream ||= Stream.new(repo, since: since)
end