Class: Gitlab::Triage::Policies::BasePolicy
- Inherits:
-
Object
- Object
- Gitlab::Triage::Policies::BasePolicy
show all
- Defined in:
- lib/gitlab/triage/policies/base_policy.rb
Constant Summary
collapse
- InvalidPolicyError =
Class.new(StandardError)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(type, policy_spec, resources, network) ⇒ BasePolicy
Returns a new instance of BasePolicy.
12
13
14
15
16
17
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 12
def initialize(type, policy_spec, resources, network)
@type = type
@policy_spec = policy_spec
@resources = resources
@network = network
end
|
Instance Attribute Details
#network ⇒ Object
Returns the value of attribute network.
9
10
11
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 9
def network
@network
end
|
#policy_spec ⇒ Object
Returns the value of attribute policy_spec.
9
10
11
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 9
def policy_spec
@policy_spec
end
|
#resources ⇒ Object
Returns the value of attribute resources.
9
10
11
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 9
def resources
@resources
end
|
#summary ⇒ Object
Returns the value of attribute summary.
10
11
12
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 10
def summary
@summary
end
|
#type ⇒ Object
Returns the value of attribute type.
9
10
11
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 9
def type
@type
end
|
Instance Method Details
#actions ⇒ Object
45
46
47
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 45
def actions
@actions ||= policy_spec.fetch(:actions) { {} }
end
|
#build_issue ⇒ Object
70
71
72
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 70
def build_issue
raise NotImplementedError
end
|
#build_summary ⇒ Object
74
75
76
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 74
def build_summary
raise NotImplementedError
end
|
57
58
59
60
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 57
def
(actions.keys.map(&:to_sym) - [:summarize, :comment_on_summary, :delete, :issue]).any?
end
|
53
54
55
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 53
def
actions.key?(:comment_on_summary)
end
|
#delete? ⇒ Boolean
66
67
68
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 66
def delete?
actions.key?(:delete) && actions[:delete]
end
|
#issue? ⇒ Boolean
62
63
64
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 62
def issue?
actions.key?(:issue)
end
|
#name ⇒ Object
23
24
25
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 23
def name
@name ||= (policy_spec[:name] || "#{type}-#{object_id}")
end
|
#source ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 27
def source
case type
when 'epics'
'groups'
else
'projects'
end
end
|
#source_id_sym ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 36
def source_id_sym
case type
when 'epics'
:group_id
else
:project_id
end
end
|
#summarize? ⇒ Boolean
49
50
51
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 49
def summarize?
actions.key?(:summarize)
end
|
#validate! ⇒ Object
19
20
21
|
# File 'lib/gitlab/triage/policies/base_policy.rb', line 19
def validate!
raise InvalidPolicyError, 'Policies that comment_on_summary must include summarize action' if && !summarize?
end
|