Welcome to mirror list, hosted at ThFree Co, Russian Federation.

unknown.rb « arguments « input « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5873e6e66a6a0afb3b9ba4db2dfbf856b3151807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# frozen_string_literal: true

module Gitlab
  module Ci
    module Input
      module Arguments
        ##
        # Input::Arguments::Unknown object gets fabricated when we can't match an input argument entry with any known
        # specification. It is matched as the last one, and always returns an error.
        #
        class Unknown < Input::Arguments::Base
          def validate!
            if spec.is_a?(Hash) && spec.count == 1
              error("unrecognized input argument specification: `#{spec.each_key.first}`")
            else
              error('unrecognized input argument definition')
            end
          end

          def to_value
            raise ArgumentError, 'unknown argument value'
          end

          def self.matches?(*)
            true
          end
        end
      end
    end
  end
end