diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-08-08 09:52:30 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-08-08 09:52:30 +0900 |
| commit | 66c505985742d8472d236f493ac1139a9ae287ca (patch) | |
| tree | 76f385957139aaed99d819bb3a7f2e4d4695cc12 /pygerrit/events.py | |
| parent | 68c2e97fea4acf4268699fa43e2dbfa2d093ae5c (diff) | |
| download | pygerrit-66c505985742d8472d236f493ac1139a9ae287ca.tar.gz | |
GerritEventFactory should be a singleton
Make the event factory a singleton, and add unit tests to verify
that it is.
Change-Id: Ieee026b9f7e1d408ade47106b71c352e7bfabdd4
Diffstat (limited to 'pygerrit/events.py')
| -rw-r--r-- | pygerrit/events.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pygerrit/events.py b/pygerrit/events.py index 4a7200d..008d942 100644 --- a/pygerrit/events.py +++ b/pygerrit/events.py @@ -9,6 +9,14 @@ class GerritEventFactory(object): """ Gerrit event factory. """ _events = {} + _instance = None + + def __new__(cls, *args, **kwargs): + """ Return the event factory instance. """ + if not cls._instance: + cls._instance = super(GerritEventFactory, cls).__new__(cls, *args, + **kwargs) + return cls._instance @classmethod def register(cls, name): |
