Sha256: d15d9cb9a615071919dbe0b933b272684f3c4782a6667781e61ea1f956f5cd0b

Contents?: true

Size: 1.39 KB

Versions: 25

Compression:

Stored size: 1.39 KB

Contents

module ProconBypassMan
  module RemotePbmAction
    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::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
      end

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

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

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.5 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.23 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.22 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.21 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.20.2 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.20.1 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.20 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.19.1 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.19 lib/procon_bypass_man/remote_pbm_action/base_action.rb
procon_bypass_man-0.1.18 lib/procon_bypass_man/remote_pbm_action/base_action.rb