Sha256: 31671aecfa317feeccc4ddaaa10297a03f45187b8bd6377f9967b67e4b756607

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

module Faraday
  class Middleware
    extend MiddlewareRegistry

    class << self
      attr_accessor :load_error
      private :load_error=
    end

    self.load_error = nil

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

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

    def self.loaded?
      load_error.nil?
    end

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

    def self.adapter?
      false
    end

    def initialize(app = nil)
      @app = app
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
avdi-faraday-0.8.1 lib/faraday/middleware.rb