Class: Async::Runner::Controller

Inherits:
Container::Controller
  • Object
show all
Defined in:
lib/async/runner/controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Controller

Returns a new instance of Controller.



8
9
10
11
# File 'lib/async/runner/controller.rb', line 8

def initialize(command)
  @command = command
  super()
end

Class Method Details

.run(command) ⇒ Object



4
5
6
# File 'lib/async/runner/controller.rb', line 4

def self.run(command)
  new(command).run
end

Instance Method Details

#create_containerObject



13
14
15
# File 'lib/async/runner/controller.rb', line 13

def create_container
  @command.container_class.new
end

#create_jobObject



17
18
19
# File 'lib/async/runner/controller.rb', line 17

def create_job
  @command.job_class.new(@command.file, **@command.options)
end

#setup(container) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/async/runner/controller.rb', line 21

def setup(container)
  @job = create_job
  @job.setup

  container.run name: @command.file, **@command.container_options do |instance|
    instance.ready!
    Sync do
      @job.execute
    end
  end
end