Sha256: 97746221310f6903a39cdd4c1e7949f091d3862beefe686c6d88c74595d28178

Contents?: true

Size: 1.2 KB

Versions: 8

Compression:

Stored size: 1.2 KB

Contents

module ProconBypassMan
  class RemotePbmJobObject
    # valueobjectがvalidatorの責務も持っている. 今度分離する
    class ValidationError < StandardError; end
    class MustBeNotNilError < ValidationError; end
    class NonSupportAction < ValidationError; end

    attr_accessor :action, :status, :uuid, :created_at, :job_args

    # @param [String] action
    # @param [String] status
    # @param [String] #uuid
    # @param [Time] created_at
    # @param [Hash] job_args
    def initialize(action: , status:, uuid:, created_at:, job_args: )
      self.action = action
      self.status = status
      self.uuid = uuid
      self.created_at = created_at
      self.job_args = job_args

      freeze
    end

    # @raise [MustBeNotNilError]
    # @raise [NonSupportAction]
    # @return [void]
    def validate!
      self.action or raise MustBeNotNilError, "actionは値が必須です"
      self.status or raise MustBeNotNilError, "statusは値が必須です"
      self.uuid or raise MustBeNotNilError, "uuidは値が必須です"

      unless ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS.include?(action)
        raise NonSupportAction, "知らないアクションです"
      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/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb