Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 964 Bytes

ooze_provide_static.rst

File metadata and controls

32 lines (22 loc) · 964 Bytes

The ooze.provide_static function

Overview

The Ooze dependency injector isn't limited to only injecting functions and classes. It can inject any valid Python value. The ooze.provide_static function makes it easy:

1 import ooze
2 
3 ooze.provide_static('application_version', '1.0.0')
4 ooze.provide_static('config', { 'env': 'prod', 'url': 'https://github.com/' })

The first argument is the name that you want the item to known as in the dependency graph. The second argument is the value. Later in your application, you can have these values injected into your functions simply by naming your arguments:

1 import ooze
2 
3 @ooze.provide
4 def get_app_status(application_version, config):
5     return f"App version: {application_version}, environment: {config['env']}"