Module: Kiba::Extend::Command::Runnable

Included in:
Run
Defined in:
lib/kiba/extend/command/runnable.rb

Class Method Summary collapse

Class Method Details

.resolve_creator(job) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/kiba/extend/command/runnable.rb', line 16

def resolve_creator(job)
  creator = job.creator
  return creator if creator

  puts "No creator method for #{job.key}"
  :failure
end

.resolve_job(key) ⇒ Object



9
10
11
12
13
14
# File 'lib/kiba/extend/command/runnable.rb', line 9

def resolve_job(key)
  Kiba::Extend.registry.resolve(key)
rescue Dry::Container::KeyError
  puts "No job with key: #{key}"
  :failure
end

.run_job(key) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'lib/kiba/extend/command/runnable.rb', line 24

def run_job(key)
  job = resolve_job(key)
  return if job == :failure

  creator = resolve_creator(job)
  return if creator == :failure

  creator.call
end