Prototype inline injections

This commit is contained in:
Roman Mogylatov 2021-02-25 09:45:07 -05:00
parent 73d9c97c1b
commit b882c7cdf3

View File

@ -64,6 +64,8 @@ def _setup_injections(
if isinstance(arg, str): if isinstance(arg, str):
injection = _resolve_provider(container, arg) injection = _resolve_provider(container, arg)
# TODO: add inline injections
if not injection: if not injection:
injection = arg injection = arg
@ -79,6 +81,19 @@ def _setup_injections(
if isinstance(arg, str): if isinstance(arg, str):
injection = _resolve_provider(container, arg) injection = _resolve_provider(container, arg)
# TODO: refactoring
if isinstance(arg, dict):
provider_args = []
provider_type = _get_provider_cls(arg.get('provider'))
provides = arg.get('provides')
if provides:
provides = _import_string(provides)
if provides:
provider_args.append(provides)
for provider_arg in arg.get('args', []):
provider_args.append(_resolve_provider(container, provider_arg))
injection = provider_type(*provider_args)
if not injection: if not injection:
injection = arg injection = arg