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
84 85 86 87 |
# File 'lib/faraday.rb', line 84 def all_loaded_constants constants.map { |c| const_get(c) }. select { |a| a.respond_to?(:loaded?) && a.loaded? } end |
#autoload_all(prefix, options) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/faraday.rb', line 67 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.
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 |