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
cocRb-0.1.0 .bundle/ruby/3.0.0/gems/faraday-1.4.1/lib/faraday/dependency_loader.rb
faraday-1.4.1 lib/faraday/dependency_loader.rb
faraday-1.4.0 lib/faraday/dependency_loader.rb
faraday-1.3.1 lib/faraday/dependency_loader.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/faraday-1.2.0/lib/faraday/dependency_loader.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/faraday-1.3.0/lib/faraday/dependency_loader.rb
logstash-output-newrelic-1.2.0 vendor/bundle/jruby/2.5.0/gems/faraday-1.3.0/lib/faraday/dependency_loader.rb
faraday-1.3.0 lib/faraday/dependency_loader.rb
faraday-1.2.0 lib/faraday/dependency_loader.rb
passbase-1.0.2 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
passbase-1.0.1 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
passbase-1.0.0 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
logstash-filter-csharp-0.2.1 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
logstash-filter-csharp-0.2.0 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
tdiary-5.1.3 vendor/bundle/ruby/2.7.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
tdiary-5.1.3 vendor/bundle/ruby/2.6.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
logstash-output-scalyr-0.1.5 vendor/bundle/jruby/2.5.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb
files.com-1.0.1 vendor/bundle/ruby/2.5.0/gems/faraday-1.0.1/lib/faraday/dependency_loader.rb