injector
Injector - Python dependency injection framework, inspired by Guice
デコレータ @inject
Decorator declaring parameters to be injected.
__init__へのデコレート
This decorator is to be used on class constructors
Injector クラス
イニシャライザ
modules引数
a configuration module or iterable of configuration modules. Each module will be installed in current Binder using Binder.install().
getメソッド
getはrootのオブジェクトを作るためのもの。rootのオブジェクトが作る依存は@injectされる
Full exampleでは以下2つを渡している
binderを受け取る関数(関数の中でbinderにbindしている)
Moduleを継承したクラス
Module
Configures injector and providers.
InjectorクラスによるとModuleはBinderによってインストールされるらしい
Binder
Bind interfaces to implementations.
bindメソッド
binder.bind(A, to=A('some', 'thing'))
binder.bind(A, to=InstanceProvider(A('some', 'thing')))と同じ