Module: Dio
- Defined in:
- lib/dio.rb,
lib/dio/equip.rb,
lib/dio/rails.rb,
lib/dio/state.rb,
lib/dio/version.rb,
lib/dio/injector.rb,
lib/dio/container.rb,
lib/dio/module_base.rb,
lib/dio/rails/model.rb,
lib/dio/load_context.rb,
lib/dio/injector_store.rb,
lib/dio/loader_factory.rb,
lib/dio/rails/controller.rb
Overview
Dio provides DI functionality. Note that most of the methods this module provides are defined at ModuleBase.
Defined Under Namespace
Modules: Equip, ModuleBase, Rails Classes: Container, Injector, InjectorStore, LoadContext, LoaderFactory, State
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
-
.default_injector ⇒ Dio::Injector
Returns a default Injector.
-
.depends(*_args) ⇒ Object
Currently this method does nothing.
-
.use(injector_id, injector = nil) ⇒ Dio::ModuleBase
Creates a new Dio module with the specified Injector.
Class Method Details
.default_injector ⇒ Dio::Injector
Returns a default Injector. By default all dependencies are registered and loaded via this injector. Its injector ID is ‘:default`.
43 44 45 |
# File 'lib/dio.rb', line 43 def self.default_injector injector end |
.depends(*_args) ⇒ Object
Currently this method does nothing. This method is intended to be used in the following situation.
-
You use a dependencies provider class
-
The provider class is autoloadable (you can’t ‘require` it explicitly)
In that case, you need to autoload the provider class before using dependencies it provides. You can use this noop method for that purpose.
75 |
# File 'lib/dio.rb', line 75 def self.depends(*_args); end |
.use(injector_id, injector = nil) ⇒ Dio::ModuleBase
Creates a new Dio module with the specified Injector. You can use several injectors using this method.
29 30 31 32 33 34 35 36 |
# File 'lib/dio.rb', line 29 def self.use(injector_id, injector = nil) Equip.equip_dio( injector_id: injector_id, state: @state, base_module: Module.new, injector: injector, ) end |