class Hypernova::Batch

Attributes

jobs[R]
service[RW]

Public Class Methods

new(service) click to toggle source

@param service the Hypernova backend service to use for render_react_batch The only requirement for the `service` object is the method render_react_batch

which should accept a Hash of { job_token
Scalar => job_data

Hash }

the subscript operator, to access result via tokens

# File lib/hypernova/batch.rb, line 17
def initialize(service)
  # TODO: make hashmap instead????
  @jobs = []
  @service = service
end

Public Instance Methods

render(job) click to toggle source
# File lib/hypernova/batch.rb, line 23
def render(job)
  Hypernova.verify_job_shape(job)
  token = jobs.length
  jobs << job
  token.to_s
end
submit!() click to toggle source
# File lib/hypernova/batch.rb, line 30
def submit!
  service.render_batch(jobs_hash)
end
submit_fallback!() click to toggle source
# File lib/hypernova/batch.rb, line 34
def submit_fallback!
  service.render_batch_blank(jobs_hash)
end

Private Instance Methods

jobs_hash() click to toggle source

creates a hash with each index mapped to the value at that index

# File lib/hypernova/batch.rb, line 43
def jobs_hash
  hash = {}
  jobs.each_with_index { |job, idx| hash[idx.to_s] = job }
  hash
end