Sha256: 706687835b6563d2427e91a0999bb49ac0527bd1433c3f766ce46711df7a0fbb

Contents?: true

Size: 1.49 KB

Versions: 8

Compression:

Stored size: 1.49 KB

Contents

module ProconBypassMan
  module RemoteAction
    module RemotePbmJob
      class ActionUnexpectedError < StandardError; end
      class NeedPbmVersionError < ActionUnexpectedError; end

      class BaseAction
        attr_accessor :pbm_job_uuid

        # @param [String] pbm_job_uuid
        def initialize(pbm_job_uuid: )
          self.pbm_job_uuid = pbm_job_uuid
        end

        # @return [void]
        def action_content(_args)
          raise NotImplementedError, nil
        end

        # @param [Hash] args
        # @return [void]
        def run!(job_args: )
          before_action_callback
          action_content(args: job_args)
          after_action_callback
        rescue => e
          be_failed
          ProconBypassMan::SendErrorCommand.execute(error: e)
        end

        private

        # @return [void]
        def before_action_callback; end
        # @return [void]
        def after_action_callback; end

        # @return [void]
        def be_failed
          ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
        end

        # @return [void]
        def be_in_progress
          ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :in_progress)
        end

        # @return [void]
        def be_processed
          ProconBypassMan::UpdateRemotePbmJobStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :processed)
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb