Sha256: b462cc26c0fac6a40aeb8c74fa99869cacfed806fa7887083195256f41e89277

Contents?: true

Size: 1.67 KB

Versions: 15

Compression:

Stored size: 1.67 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/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

      # @return [Array<Contrast::Agent::Reporting::DiscoveredRoute>]
      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

15 entries across 15 versions & 1 rubygems

Version Path
contrast-agent-6.11.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.10.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.9.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.8.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.7.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.5 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.4 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.3 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.2 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.1 lib/contrast/framework/manager_extend.rb
contrast-agent-6.6.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.5.1 lib/contrast/framework/manager_extend.rb
contrast-agent-6.5.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.4.0 lib/contrast/framework/manager_extend.rb
contrast-agent-6.3.0 lib/contrast/framework/manager_extend.rb