Sha256: fb57cbaaea4f28a358291ea3ad5712fc6be0b24a7eb7bb65371d2561f2ecd9b7

Contents?: true

Size: 558 Bytes

Versions: 6

Compression:

Stored size: 558 Bytes

Contents

# frozen_string_literal: true

require 'monitor'

module Faraday
  # AdapterRegistry registers adapter class names so they can be looked up by a
  # String or Symbol name.
  class AdapterRegistry
    def initialize
      @lock = Monitor.new
      @constants = {}
    end

    def get(name)
      klass = @constants[name]
      return klass if klass

      Object.const_get(name).tap { |c| set(c, name) }
    end

    def set(klass, name = nil)
      name ||= klass.to_s
      @lock.synchronize do
        @constants[name] = klass
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
tdiary-5.1.1 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.0/lib/faraday/adapter_registry.rb
faraday-1.0.0 lib/faraday/adapter_registry.rb
faraday-0.16.2 lib/faraday/adapter_registry.rb
faraday-0.16.1 lib/faraday/adapter_registry.rb
faraday-0.16.0 lib/faraday/adapter_registry.rb
faraday-1.0.0.pre.rc1 lib/faraday/adapter_registry.rb