diff --git a/lib/tfw/decorators/lazy_property.py b/lib/tfw/decorators/lazy_property.py index c7e00c6..14ad788 100644 --- a/lib/tfw/decorators/lazy_property.py +++ b/lib/tfw/decorators/lazy_property.py @@ -1,7 +1,7 @@ # Copyright (C) 2018 Avatao.com Innovative Learning Kft. # All Rights Reserved. See LICENSE file for details. -from functools import update_wrapper +from functools import update_wrapper, wraps class lazy_property: @@ -19,3 +19,12 @@ class lazy_property: value = self.func(instance) setattr(instance, self.func.__name__, value) return value + + +def lazy_factory(fun): + class wrapper: + @wraps(fun) + @lazy_property + def instance(self): # pylint: disable=no-self-use + return fun() + return wrapper()