Class: Kiba::Extend::Utils::PreJobTask

Inherits:
Object
  • Object
show all
Defined in:
lib/kiba/extend/utils/pre_job_task.rb

Direct Known Subclasses

PreJobBackupTask, PreJobNukeTask

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePreJobTask

Returns a new instance of PreJobTask.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/kiba/extend/utils/pre_job_task.rb', line 36

def initialize
  return unless configured?(:pre_job_task_mode)

  mode_setting = Kiba::Extend.pre_job_task_mode
  return unless mode_setting == :job

  @mode = mode_setting
  return unless configured?(:pre_job_task_directories)

  dirs_setting = Kiba::Extend.pre_job_task_directories
  return unless valid_dirs?(dirs_setting)

  @dirs = dirs_setting.select { |dir| Dir.exist?(dir) }
end

Class Method Details

.callObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/kiba/extend/utils/pre_job_task.rb', line 8

def call
  use_setting = :pre_job_task_run
  # rubocop:todo Layout/LineLength
  return unless Kiba::Extend.respond_to?(use_setting) && Kiba::Extend.send(use_setting)
  # rubocop:enable Layout/LineLength

  action = Kiba::Extend.pre_job_task_action
  return unless action && valid_action?(action)

  case action
  when :backup then Kiba::Extend::Utils::PreJobBackupTask.call
  when :nuke then Kiba::Extend::Utils::PreJobNukeTask.call
  end
end