Sha256: 43797d92de12fb624e8b4740d8904050ccbb5a29c3744aa242cccf62065996be
Contents?: true
Size: 1.2 KB
Versions: 2
Compression:
Stored size: 1.2 KB
Contents
# encoding: utf-8 # module Mode module Sdk # Represents the status of a Mode table import job # class TableImport # Construct a new TableImport instance # # @param resource_path [String] Mode API resource path # # @return [Mode::Sdk::TableImport] the instance # def initialize(resource_path) @resource_path = resource_path end # Poll the API representation of the table import until the job is no # longer running # # @param interval [optional, Integer, Float] polling interval in seconds # # @yield [Hash] the API representation of the table import job # 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 private attr_reader :resource_path # Get the API representation of the resource from the Mode API # # @return [Hash] the API representation # def fetch_repr Mode::Sdk::Client.get("#{resource_path}?embed[table]=1").body end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mode-sdk-0.1.0 | lib/mode/sdk/table_import.rb |
mode-sdk-0.0.1 | lib/mode/sdk/table_import.rb |