Module: Faraday::AutoloadHelper
Instance Method Summary collapse
- #all_loaded_constants ⇒ Object
- #autoload_all(prefix, options) ⇒ Object
-
#load_autoloaded_constants ⇒ Object
Loads each autoloaded constant.
- #lookup_module(key) ⇒ Object
- #register_lookup_modules(mods) ⇒ Object
Instance Method Details
#all_loaded_constants ⇒ Object
84 85 86 |
# File 'lib/faraday.rb', line 84 def all_loaded_constants constants.map { |c| const_get(c) }.select { |a| a.loaded? } end |
#autoload_all(prefix, options) ⇒ Object
70 71 72 73 74 |
# File 'lib/faraday.rb', line 70 def autoload_all(prefix, ) .each do |const_name, path| autoload const_name, File.join(prefix, path) end end |
#load_autoloaded_constants ⇒ Object
Loads each autoloaded constant. If thread safety is a concern, wrap this in a Mutex.
78 79 80 81 82 |
# File 'lib/faraday.rb', line 78 def load_autoloaded_constants constants.each do |const| const_get(const) if autoload?(const) end end |
#lookup_module(key) ⇒ Object
65 66 67 68 |
# File 'lib/faraday.rb', line 65 def lookup_module(key) return if !@lookup_module_index const_get @lookup_module_index[key] || key end |
#register_lookup_modules(mods) ⇒ Object
61 62 63 |
# File 'lib/faraday.rb', line 61 def register_lookup_modules(mods) (@lookup_module_index ||= {}).update(mods) end |