Sha256: 99aa09ee317dc9d4696ec8ea7dc9eaf7a0ad3d4a6c81cc2b2261a3636bb706dd
Contents?: true
Size: 1.83 KB
Versions: 17
Compression:
Stored size: 1.83 KB
Contents
# Copyright (c) 2023 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/components/logger' module Contrast module Agent module Reporting # This module will be used to store everything that would be sent # and depends on the response we receive module ReportingStorage class << self include Contrast::Components::Logger::InstanceMethods # So the collection will be used to store those events def collection @_collection ||= {} end # @param key[String] the key for the pair # @param value[Object] the value we need to store # @return [Object] the value we saved def []= key, value return unless key return unless value logger.debug('Saving new value', key: key) key = key.to_s.downcase.strip collection[key] = value value # rubocop:disable Lint/Void end # @param key[String] the key for the pair def [] key return unless key collection[key] end alias_method :get, :[] alias_method :set, :[]= def delete key return unless key logger.debug('Starting deleting value for', key: key) deleted_value = collection.delete(key) logger.debug('Key wasn\'t found') unless deleted_value deleted_value end # @param rule_id [String] the rule_id # @return [Array, nil] return array with key and value of the pair def find_by_rule_id rule_id return unless rule_id collection.find { |_, v| v.rule_id == rule_id } end end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems