blob: b8a275b6c327330a66466f3764ecdaca7f6e1f6f (
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# frozen_string_literal: true
module MergeRequests
module Mergeability
class CheckBaseService
attr_reader :merge_request, :params
def initialize(merge_request:, params:)
@merge_request = merge_request
@params = params
end
def self.identifier
failure_reason
end
def skip?
raise NotImplementedError
end
# When this method is true, we need to implement a cache_key
def cacheable?
raise NotImplementedError
end
def cache_key
raise NotImplementedError
end
private
def failure_reason
self.class.failure_reason
end
def success(**args)
Gitlab::MergeRequests::Mergeability::CheckResult
.success(payload: default_payload(args))
end
def failure(**args)
Gitlab::MergeRequests::Mergeability::CheckResult
.failed(payload: default_payload(args))
end
def inactive(**args)
Gitlab::MergeRequests::Mergeability::CheckResult
.inactive(payload: default_payload(args))
end
def default_payload(args)
args.merge(identifier: self.class.identifier)
end
end
end
end
|