2015-03-09 01:01:39 +03:00
|
|
|
"""Injections module."""
|
2015-01-10 12:24:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Injection(object):
|
2015-03-09 01:01:39 +03:00
|
|
|
|
|
|
|
"""Base injection class."""
|
2015-01-10 12:24:25 +03:00
|
|
|
|
|
|
|
def __init__(self, name, injectable):
|
2015-03-09 01:01:39 +03:00
|
|
|
"""Initializer."""
|
2015-01-10 12:24:25 +03:00
|
|
|
self.name = name
|
|
|
|
self.injectable = injectable
|
|
|
|
|
2015-01-11 16:03:45 +03:00
|
|
|
@property
|
|
|
|
def value(self):
|
2015-03-09 01:01:39 +03:00
|
|
|
"""Return injectable value."""
|
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):
|
2015-03-09 01:01:39 +03:00
|
|
|
|
|
|
|
"""Init argument injection."""
|
2015-01-10 12:24:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Attribute(Injection):
|
2015-03-09 01:01:39 +03:00
|
|
|
|
|
|
|
"""Attribute injection."""
|
2015-01-10 12:24:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Method(Injection):
|
2015-03-09 01:01:39 +03:00
|
|
|
|
|
|
|
"""Method injection."""
|