Sha256: ad0195d5d90bcc7b7ddf483fedc3e2e076827edda6b11da61a577ab42f5218a1
Contents?: true
Size: 1.26 KB
Versions: 6
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Datadog module AppSec class Processor # Actions store the actions information in memory # Also, takes care of merging when RC send new information module Actions class << self def actions @actions ||= [] end def fetch_configuration(action) actions.find { |action_configuration| action_configuration['id'] == action } end def merge(actions_to_merge) return if actions_to_merge.empty? if actions.empty? @actions = actions_to_merge else merged_actions = [] actions_dup = actions.dup actions_to_merge.each do |new_action| existing_action = actions_dup.find { |action| new_action['id'] == action['id'] } # the old action is discard and the new kept actions_dup.delete(existing_action) if existing_action merged_actions << new_action end @actions = merged_actions.concat(actions_dup) end end private # Used in tests def reset @actions = [] end end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems