Class: Hypernova::Batch

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hypernova/batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service) ⇒ 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

Parameters:

  • service

    the Hypernova backend service to use for render_react_batch



17
18
19
20
21
# File 'lib/hypernova/batch.rb', line 17

def initialize(service)
  # TODO: make hashmap instead????
  @jobs = []
  @service = service
end

Instance Attribute Details

#jobsObject (readonly)

Returns the value of attribute jobs.



8
9
10
# File 'lib/hypernova/batch.rb', line 8

def jobs
  @jobs
end

#service=(value) ⇒ Object

Sets the attribute service

Parameters:

  • value

    the value to set the attribute service to.



7
8
9
# File 'lib/hypernova/batch.rb', line 7

def service=(value)
  @service = value
end

Instance Method Details

#render(job) ⇒ Object



23
24
25
26
27
28
# 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!Object



30
31
32
# File 'lib/hypernova/batch.rb', line 30

def submit!
  service.render_batch(jobs_hash)
end

#submit_fallback!Object



34
35
36
# File 'lib/hypernova/batch.rb', line 34

def submit_fallback!
  service.render_batch_blank(jobs_hash)
end