# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true require 'contrast/utils/string_utils' module Contrast module Api module Decorators # Used to decorate the {Contrast::Api::Dtm::Activity} protobuf model # to handle conversion between framework route classes and the dtm. module Activity def self.included klass klass.extend(ClassMethods) end # Class methods for Activity module ClassMethods def source_or_string obj if obj.cs__is_a?(Regexp) obj.source elsif obj.cs__respond_to?(:safe_string) obj.safe_string else obj.to_s end end end end end end end Contrast::Api::Dtm::Activity.include(Contrast::Api::Decorators::Activity)