Skip to content

Commit

Permalink
redminelib/resources: add eq metamethod
Browse files Browse the repository at this point in the history
To test whether, for example, a project looked up earlier is equal to
the project associated with an issue or tracker.

Signed-off-by: Patrick Donnelly <batrick@batbytes.com>
  • Loading branch information
batrick committed May 10, 2024
1 parent 785de4c commit f71e213
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions redminelib/resources/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def __init__(self, manager, attributes):
if self._relations_name is None:
self._relations_name = self.__class__.__name__.lower()

def __eq__(self, other):
if isinstance(other, self.__class__):
return self.internal_id == other.internal_id
else:
return False

def __getitem__(self, item):
"""
Provides dictionary-like access to Resource attributes.
Expand Down

0 comments on commit f71e213

Please sign in to comment.