Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

references: make RecordResolver extensible via properties #490

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions invenio_records_resources/references/entity_resolvers/records.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,28 @@ def __init__(
:param record_cls: The record class to use.
:param service_id: The record service id.
:param type_key: The value to use for the TYPE part of the ref_dicts.
:param proxy_cls: The record proxy class to use.
"""
self.record_cls = record_cls
self.type_key = type_key
self.proxy_cls = proxy_cls
self._record_cls = record_cls
self._type_key = type_key
self._proxy_cls = proxy_cls
super().__init__(service_id)

@property
def record_cls(self):
"""Return the record class."""
return self._record_cls

@property
def type_key(self):
"""Return the type key for the ref_dicts."""
return self._type_key

@property
def proxy_cls(self):
"""Return the proxy class."""
return self._proxy_cls

def matches_entity(self, entity):
"""Check if the entity is a record."""
return isinstance(entity, self.record_cls)
Expand Down