Sha256: 2cb66c16f9290d45856e65eb48a1d87c210afe681eb5670151b1d09cc4cb16b2

Contents?: true

Size: 827 Bytes

Versions: 1

Compression:

Stored size: 827 Bytes

Contents

module ILove
  module Tracing
    module FaradayMiddleware
      @@active_middleware = Set.new

      def self.active_middleware
        @@active_middleware
      end

      def self.add_active_middleware(middleware)
        @@active_middleware << middleware
      end

      module FaradayConnectionOptions
        def new_builder(block)
          super.tap do |builder|
            ILove::Tracing::FaradayMiddleware.active_middleware.each do |middleware|
              builder.insert(0, middleware)
            end
          end
        end
      end

      def self.setup(cfg)
        return if active_middleware.empty?
        raise 'Faraday is not defined, can not add required outgoing middleware' unless defined?(Faraday)

        Faraday::ConnectionOptions.prepend(FaradayConnectionOptions)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ilove-tracing-0.2.0 lib/ilove/tracing/faraday_middleware.rb