Sha256: abc0dd07c356d0c2c3c51cc70f1d7ef462e2341763ea03e6a3c334eef7873ab2
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true module Gitlab module Triage module Policies class BasePolicy InvalidPolicyError = Class.new(StandardError) attr_reader :type, :policy_spec, :resources, :network attr_accessor :summary def initialize(type, policy_spec, resources, network) @type = type @policy_spec = policy_spec @resources = resources @network = network end def validate! raise InvalidPolicyError, 'Policies that comment_on_summary must include summarize action' if comment_on_summary? && !summarize? end def name @name ||= (policy_spec[:name] || "#{type}-#{object_id}") end def source case type when 'epics' 'groups' else 'projects' end end def source_id_sym case type when 'epics' :group_id else :project_id end end def actions @actions ||= policy_spec.fetch(:actions) { {} } end def summarize? actions.key?(:summarize) end def comment_on_summary? actions.key?(:comment_on_summary) end def comment? # The actual keys are strings (actions.keys.map(&:to_sym) - [:summarize, :comment_on_summary]).any? end def issue? actions.key?(:issue) end def build_issue raise NotImplementedError end def build_summary raise NotImplementedError end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gitlab-triage-1.24.0 | lib/gitlab/triage/policies/base_policy.rb |