Module: Faraday::AutoloadHelper
Instance Method Summary collapse
- #all_loaded_constants ⇒ Object
- #autoload_all(prefix, options) ⇒ Object
-
#load_autoloaded_constants ⇒ Object
Loads each autoloaded constant.
Instance Method Details
#all_loaded_constants ⇒ Object
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, ) if prefix =~ /^faraday(\/|$)/i prefix = File.join(Faraday.root_path, prefix) end .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.
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 |