Sha256: 81b48c5d10126940d31fd82e20a1fa25159dfbc35f645f140f738c746bd2950d

Contents?: true

Size: 736 Bytes

Versions: 71

Compression:

Stored size: 736 Bytes

Contents

# frozen_string_literal: true

module Faraday
  # DependencyLoader helps Faraday adapters and middleware load dependencies.
  module DependencyLoader
    attr_reader :load_error

    # Executes a block which should try to require and reference dependent
    # libraries
    def dependency(lib = nil)
      lib ? require(lib) : yield
    rescue LoadError, NameError => e
      self.load_error = e
    end

    def new(*)
      unless loaded?
        raise "missing dependency for #{self}: #{load_error.message}"
      end

      super
    end

    def loaded?
      load_error.nil?
    end

    def inherited(subclass)
      super
      subclass.send(:load_error=, load_error)
    end

    private

    attr_writer :load_error
  end
end

Version data entries

71 entries across 62 versions & 14 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/faraday-1.2.0/lib/faraday/dependency_loader.rb
faraday-1.10.2 lib/faraday/dependency_loader.rb
faraday-1.10.1 lib/faraday/dependency_loader.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
op_connect-0.1.2 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb
plaid-14.13.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb
tdiary-5.2.1 vendor/bundle/ruby/3.1.0/gems/faraday-1.10.0/lib/faraday/dependency_loader.rb
faraday-1.10.0 lib/faraday/dependency_loader.rb
plaid-14.12.1 vendor/bundle/ruby/3.0.0/gems/faraday-1.9.3/lib/faraday/dependency_loader.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/dependency_loader.rb
plaid-14.12.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.9.3/lib/faraday/dependency_loader.rb
plaid-14.11.1 vendor/bundle/ruby/2.6.0/gems/faraday-1.9.3/lib/faraday/dependency_loader.rb
faraday-1.9.3 lib/faraday/dependency_loader.rb
faraday-1.9.2 lib/faraday/dependency_loader.rb
faraday-1.9.1 lib/faraday/dependency_loader.rb
faraday-1.9.0 lib/faraday/dependency_loader.rb
plaid-14.10.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/dependency_loader.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/faraday-1.8.0/lib/faraday/dependency_loader.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.4.2/lib/faraday/dependency_loader.rb
plaid-14.7.0 vendor/bundle/ruby/2.6.0/gems/faraday-1.8.0/lib/faraday/dependency_loader.rb