Sha256: 5e478c7ae1048cf0cb24c63e169c819de378e8e709a18f5f6bacb0e1bebcf7bc

Contents?: true

Size: 1.2 KB

Versions: 13

Compression:

Stored size: 1.2 KB

Contents

module ProconBypassMan
  class RemotePbmActionObject
    # 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::RemotePbmAction::ACTIONS.include?(action)
        raise NonSupportAction, "知らないアクションです"
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.5 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.1.23 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
procon_bypass_man-0.1.22 lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb