Created
November 4, 2014 22:07
-
-
Save dhermes/2f833d9d3706a52b559d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def _require_loaded(method): | |
| """Wrapper for an instance method to allow lazy loading.""" | |
| @functools.wraps(method) | |
| def wrapped_method(self, *args, **kwargs): | |
| """Wrapped version of an instance method which requires loaded. | |
| If the instance value of loaded is not True, then this will | |
| reload before calling the method. | |
| """ | |
| if not self.loaded: | |
| self.reload() | |
| return method(self, *args, **kwargs) | |
| return wrapped_method |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment