Module: DevSuite::Utils::DependencyLoader
- Defined in:
- lib/dev_suite/utils/dependency_loader.rb
Class Method Summary collapse
-
.gem_installed?(gem_name) ⇒ Boolean
Check if a gem is installed by attempting to require it.
-
.safe_load_dependencies(dependencies = [], on_failure: method(:default_failure_handler)) { ... } ⇒ Object
Public method to safely load multiple dependencies.
Class Method Details
.gem_installed?(gem_name) ⇒ Boolean
Check if a gem is installed by attempting to require it.
28 29 30 31 32 33 |
# File 'lib/dev_suite/utils/dependency_loader.rb', line 28 def gem_installed?(gem_name) require gem_name true rescue LoadError false end |
.safe_load_dependencies(dependencies = [], on_failure: method(:default_failure_handler)) { ... } ⇒ Object
Public method to safely load multiple dependencies. Executes the given block if all dependencies are successfully loaded. Calls the on_failure handler with the list of missing dependencies if any are not found.
14 15 16 17 18 19 20 21 22 |
# File 'lib/dev_suite/utils/dependency_loader.rb', line 14 def safe_load_dependencies(dependencies = [], on_failure: method(:default_failure_handler)) missing_dependencies = find_missing_dependencies(dependencies) if missing_dependencies.empty? yield if block_given? else on_failure.call(missing_dependencies) end end |