Sha256: 320ffe3750c3572c0f79b021400627caf196cb474391c444dc844a3b3e4df16c

Contents?: true

Size: 1.65 KB

Versions: 2

Compression:

Stored size: 1.65 KB

Contents

# Copyright (c) 2022 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

require 'contrast/components/logger'
require 'contrast/extension/module'
require 'contrast/framework/platform_version'
require 'contrast/framework/rack/support'
require 'contrast/framework/rails/support'
require 'contrast/framework/grape/support'
require 'contrast/framework/sinatra/support'
require 'contrast/utils/class_util'

module Contrast
  module Framework
    # Allows access to framework specific information
    module ManagerExtend
      private

      def enable_framework_support? klass
        Contrast::Utils::ClassUtil.truly_defined?(klass)
      end

      def routes_for_all_frameworks
        data_for_all_frameworks(:collect_routes)
      end

      # This returns an array of all data from each framework in a flat, no-nil values array
      #
      # @param method_name [Symbol] the method to call on each FrameworkSupport class
      # @return [Array]
      def data_for_all_frameworks method_name
        @_frameworks.flat_map { |framework| framework.send(method_name) }.
            compact
      end

      # This returns a single object from the first framework to successfully respond
      #
      # @param method_name [Symbol] the method to call on each FrameworkSupport class
      # @return [Object] - Determined by method to be invoked
      def first_framework_result method_name, default_value
        result = nil
        @_frameworks.each do |framework|
          result = framework.send(method_name)
          break if result
        end
        result || default_value
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
contrast-agent-6.1.2 lib/contrast/framework/manager_extend.rb
contrast-agent-6.1.1 lib/contrast/framework/manager_extend.rb