Class: ProconBypassMan::RemoteAction::RemotePbmJob::RestorePbmSettingAction

Inherits:
BaseAction
  • Object
show all
Defined in:
lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb

Instance Attribute Summary

Attributes inherited from BaseAction

#pbm_job_uuid

Instance Method Summary collapse

Methods inherited from BaseAction

#initialize, #run!

Constructor Details

This class inherits a constructor from ProconBypassMan::RemoteAction::RemotePbmJob::BaseAction

Instance Method Details

#action_content(args:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb', line 6

def action_content(args: )
  require "pbmenv"
  ProconBypassMan.logger.info "execute RestorePbmSettingAction!"
  setting = args.dig("setting") or raise(ProconBypassMan::RemotePbmJob::NeedPbmVersionError, "settingが必要です, #{args.inspect}")

  # 復元に失敗したら戻せるように退避する
  FileUtils.copy(
    ProconBypassMan.buttons_setting_configuration.setting_path,
    ProconBypassMan.fallback_setting_path,
  )

  ProconBypassMan::YamlWriter.write(
    path: ProconBypassMan.buttons_setting_configuration.setting_path,
    content: setting,
  )

  hot_reload!
end