Module: Faraday::AutoloadHelper

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

Instance Method Summary collapse

Instance Method Details

#all_loaded_constantsObject



28
29
30
# File 'lib/faraday.rb', line 28

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

#autoload_all(prefix, options) ⇒ Object



14
15
16
17
18
# File 'lib/faraday.rb', line 14

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.



22
23
24
25
26
# File 'lib/faraday.rb', line 22

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

#lookup_module(key) ⇒ Object



9
10
11
12
# File 'lib/faraday.rb', line 9

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

#register_lookup_modules(mods) ⇒ Object



5
6
7
# File 'lib/faraday.rb', line 5

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