Class: Mode::Sdk::TableImport

Inherits:
Object
  • Object
show all
Defined in:
lib/mode/sdk/table_import.rb

Overview

Represents the status of a Mode table import job

Instance Method Summary collapse

Constructor Details

#initialize(resource_path) ⇒ Mode::Sdk::TableImport

Construct a new TableImport instance


14
15
16
# File 'lib/mode/sdk/table_import.rb', line 14

def initialize(resource_path)
  @resource_path = resource_path
end

Instance Method Details

#poll(interval = 0.5) {|Hash| ... } ⇒ Object

Poll the API representation of the table import until the job is no longer running

Yields:

  • (Hash)

    the API representation of the table import job


25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mode/sdk/table_import.rb', line 25

def poll(interval = 0.5)
  loop do
    repr = fetch_repr

    yield repr

    if %w(new enqueued running).include?(repr.fetch('state'))
      sleep interval
    else
      break
    end
  end
end