Module: Contrast::Agent::Reporting::ReportingStorage

Extended by:
Components::Logger::InstanceMethods
Defined in:
lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb

Overview

This module will be used to store everything that would be sent and depends on the response we receive

Class Method Summary collapse

Methods included from Components::Logger::InstanceMethods

cef_logger, logger

Class Method Details

.[](key) ⇒ Object Also known as: get



36
37
38
39
40
# File 'lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb', line 36

def [] key
  return unless key

  collection[key]
end

.[]=(key, value) ⇒ Object Also known as: set



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb', line 23

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

.collectionObject

So the collection will be used to store those events



16
17
18
# File 'lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb', line 16

def collection
  @_collection ||= {}
end

.delete(key) ⇒ Object



44
45
46
47
48
49
50
51
52
53
# File 'lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb', line 44

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

.find_by_rule_id(rule_id) ⇒ Array?



57
58
59
60
61
# File 'lib/contrast/agent/reporting/reporting_utilities/reporting_storage.rb', line 57

def find_by_rule_id rule_id
  return unless rule_id

  collection.find { |_, v| v.rule_id == rule_id }
end