python-dependency-injector/objects/injections.py

44 lines
681 B
Python
Raw Normal View History

2015-01-10 12:24:25 +03:00
"""
Injections module.
"""
class Injection(object):
"""
Base injection class.
"""
def __init__(self, name, injectable):
"""
Initializer.
"""
self.name = name
self.injectable = injectable
2015-01-11 16:03:45 +03:00
@property
def value(self):
2015-01-10 12:24:25 +03:00
"""
2015-01-11 16:03:45 +03:00
Returns injectable value.
2015-01-10 12:24:25 +03:00
"""
2015-01-11 16:03:45 +03:00
if hasattr(self.injectable, '__is_objects_provider__'):
return self.injectable()
return self.injectable
2015-01-10 12:24:25 +03:00
class InitArg(Injection):
"""
Init argument injection.
"""
class Attribute(Injection):
"""
Attribute injection.
"""
class Method(Injection):
"""
Method injection.
"""