Module: Faraday::AutoloadHelper Private
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Adds the ability for other modules to manage autoloadable constants.
Instance Method Summary collapse
-
#all_loaded_constants ⇒ Array<Class, Module>
private
Filters the module’s contents with those that have been already autoloaded.
-
#autoload_all(prefix, options) ⇒ void
private
Registers the constants to be auto loaded.
-
#load_autoloaded_constants ⇒ void
private
Loads each autoloaded constant.
Instance Method Details
#all_loaded_constants ⇒ Array<Class, Module>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Filters the module’s contents with those that have been already autoloaded.
49 50 51 52 53 |
# File 'lib/faraday/autoload.rb', line 49 def all_loaded_constants constants .map { |c| const_get(c) } .select { |a| a.respond_to?(:loaded?) && a.loaded? } end |
#autoload_all(prefix, options) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Registers the constants to be auto loaded.
25 26 27 28 29 30 31 32 33 |
# File 'lib/faraday/autoload.rb', line 25 def autoload_all(prefix, ) if prefix =~ %r{^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 ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Loads each autoloaded constant. If thread safety is a concern, wrap this in a Mutex.
39 40 41 42 43 |
# File 'lib/faraday/autoload.rb', line 39 def load_autoloaded_constants constants.each do |const| const_get(const) if autoload?(const) end end |