summaryrefslogtreecommitdiff
path: root/lib/gitlab/ci/build/rules/rule/clause.rb
blob: ff0baf3348c0667b1da1439f7d1b2a43a243af26 (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 Build
      class Rules::Rule::Clause
        ##
        # Abstract class that defines an interface of a single
        # job rule specification.
        #
        # Used for job's inclusion rules configuration.
        #
        UnknownClauseError = Class.new(StandardError)

        def self.fabricate(type, value)
          type = type.to_s.camelize

          self.const_get(type).new(value) if self.const_defined?(type)
        end

        def initialize(spec)
          @spec = spec
        end

        def satisfied_by?(pipeline, seed = nil)
          raise NotImplementedError
        end
      end
    end
  end
end