Sha256: 8e440cd4190bb3de49a7137ed5607210c3afeb9706a6807133378364dfad9c3c

Contents?: true

Size: 674 Bytes

Versions: 1

Compression:

Stored size: 674 Bytes

Contents

require 'faraday'

module VCR
  class LibraryHooks
    module Faraday
      module BuilderClassExtension
        def new(*args)
          super.extend BuilderInstanceExtension
        end

        ::Faraday::Builder.extend self
      end

      module BuilderInstanceExtension
        def lock!(*args)
          insert_vcr_middleware
          super
        end

      private

        def insert_vcr_middleware
          return if handlers.any? { |h| h.klass == VCR::Middleware::Faraday }
          adapter_index = handlers.index { |h| h.klass < ::Faraday::Adapter }
          insert_before(adapter_index, VCR::Middleware::Faraday)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcr-2.0.0.rc1 lib/vcr/library_hooks/faraday.rb