# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/agent/assess/contrast_event' require 'contrast/agent/assess/events/source_event' require 'contrast/agent/assess/events/event_data' module Contrast module Agent module Assess module Events # This module returns the event type appropriate to the given Node module EventFactory # This method returns the event type appropriate to the given Node # # @param event_data [Contrast::Agent::Assess::Events::EventData] # @param source_type [String] the type of this source, from the # source_node, or a KEY_TYPE if invoked for a map, # @param source_name [String, nil] the name of this source, i.e. # the key used to accessed if from a map or nil if a type like, # @return [Contrast::Agent::Assess::Events::SourceEvent, Contrast::Agent::Assess::ContrastEvent] def self.build event_data, source_type = nil, source_name = nil case event_data.policy_node when Contrast::Agent::Assess::Policy::SourceNode Contrast::Agent::Assess::Events::SourceEvent.new(event_data, source_type, source_name) when Contrast::Agent::Assess::Policy::PolicyNode Contrast::Agent::Assess::ContrastEvent.new(event_data) end end end end end end end