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