Module: Faraday::AutoloadHelper

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

Instance Method Summary collapse

Instance Method Details

#all_loaded_constantsObject



44
45
46
# File 'lib/faraday.rb', line 44

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

#autoload_all(prefix, options) ⇒ Object



30
31
32
33
34
# File 'lib/faraday.rb', line 30

def autoload_all(prefix, options)
  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.



38
39
40
41
42
# File 'lib/faraday.rb', line 38

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

#lookup_module(key) ⇒ Object



25
26
27
28
# File 'lib/faraday.rb', line 25

def lookup_module(key)
  return if !@lookup_module_index
  const_get @lookup_module_index[key] || key
end

#register_lookup_modules(mods) ⇒ Object



21
22
23
# File 'lib/faraday.rb', line 21

def register_lookup_modules(mods)
  (@lookup_module_index ||= {}).update(mods)
end