Module: PromptWarden::Adapter
- Defined in:
- lib/prompt_warden/adapter.rb
Defined Under Namespace
Classes: ENTRY
Constant Summary collapse
- REGISTRY =
[]
Class Method Summary collapse
- .auto_load_all! ⇒ Object
-
.map(gem_name, const_path, &block) ⇒ Object
public API ———————————————————-.
-
.try_load(gem_name) ⇒ Object
internal ————————————————————.
Class Method Details
.auto_load_all! ⇒ Object
14 15 16 17 |
# File 'lib/prompt_warden/adapter.rb', line 14 def self.auto_load_all! Gem.loaded_specs.keys.each { |name| try_load(name) } PromptWarden.configuration.run_pending_adapters end |
.map(gem_name, const_path, &block) ⇒ Object
public API ———————————————————-
9 10 11 12 |
# File 'lib/prompt_warden/adapter.rb', line 9 def self.map(gem_name, const_path, &block) REGISTRY << ENTRY.new(gem_name, const_path, block, false) try_load(gem_name) # run now if gem already active end |
.try_load(gem_name) ⇒ Object
internal ————————————————————
20 21 22 23 24 25 26 27 28 |
# File 'lib/prompt_warden/adapter.rb', line 20 def self.try_load(gem_name) entry = REGISTRY.find { |e| e.gem_name == gem_name } return unless entry && !entry.loaded return unless Gem.loaded_specs.key?(gem_name) || const_path_defined?(entry.const_path) entry.block.call entry.loaded = true end |