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
44 45 46 47 |
# File 'lib/faraday.rb', line 44 def all_loaded_constants constants.map { |c| const_get(c) }. select { |a| a.respond_to?(:loaded?) && a.loaded? } end |
#autoload_all(prefix, options) ⇒ Object
30 31 32 33 34 |
# File 'lib/faraday.rb', line 30 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.
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 |