Sha256: c88ee8d35b82ea2ee148542483aa040faa3349e020d7acd474c87cbb0c25ac2c
Contents?: true
Size: 1.5 KB
Versions: 8
Compression:
Stored size: 1.5 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 build_issue raise NotImplementedError end end end end end
Version data entries
8 entries across 8 versions & 1 rubygems