injectify.api.inject()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 15
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nop 2
dl 0
loc 15
rs 10
c 0
b 0
f 0
1
"""This module contains the apis that power Injectify."""
2
3
4
def inject(target, injector):
5
    """A decorator that injects code in the target object.
6
7
    Args:
8
        target: The object to inject code into.
9
        injector: A :class:`~injectify.injectors.BaseInjector` to represent an
10
            injection point.
11
    """
12
13
    def decorator(f):
14
        injector.prepare(target=target, handler=f)
15
        injector.compile(injector.visit_target())
16
        return f
17
18
    return decorator
19