Module: Faraday::AutoloadHelper

Included in:
Faraday, Adapter, Request, Response
Defined in:
lib/faraday.rb

Instance Method Summary collapse

Instance Method Details

#all_loaded_constantsObject



89
90
91
92
# File 'lib/faraday.rb', line 89

def all_loaded_constants
  constants.map { |c| const_get(c) }.
    select { |a| a.respond_to?(:loaded?) && a.loaded? }
end

#autoload_all(prefix, options) ⇒ Object



72
73
74
75
76
77
78
79
# File 'lib/faraday.rb', line 72

def autoload_all(prefix, options)
  if prefix =~ /^faraday(\/|$)/i
    prefix = File.join(Faraday.root_path, prefix)
  end
  options.each do |const_name, path|
    autoload const_name, File.join(prefix, path)
  end
end

#load_autoloaded_constantsObject

Loads each autoloaded constant. If thread safety is a concern, wrap this in a Mutex.



83
84
85
86
87
# File 'lib/faraday.rb', line 83

def load_autoloaded_constants
  constants.each do |const|
    const_get(const) if autoload?(const)
  end
end