Skip to content

Commit

Permalink
fix inmemory & file repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
douwevandermeij committed Mar 31, 2023
1 parent 9e197fa commit f805fd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion fractal/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."""

__version__ = "3.1.1"
__version__ = "3.1.2"

from abc import ABC

Expand Down
10 changes: 7 additions & 3 deletions fractal/core/repositories/inmemory_repository_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ def remove_one(self, specification: Specification):
if obj := self.find_one(specification):
del self.entities[obj.id]

@property
def _get_entities(self):
return self._entities if hasattr(self, "_entities") else self.entities.values()

def find_one(self, specification: Specification) -> Optional[Entity]:
for entity in filter(
lambda i: specification.is_satisfied_by(i), self.entities.values()
lambda i: specification.is_satisfied_by(i), self._get_entities
):
return entity
if self.object_not_found_exception:
Expand All @@ -44,10 +48,10 @@ def find(
) -> Iterator[Entity]:
if specification:
entities = filter(
lambda i: specification.is_satisfied_by(i), self.entities.values()
lambda i: specification.is_satisfied_by(i), self._get_entities
)
else:
entities = self.entities.values()
entities = self._get_entities

reverse = False
if order_by.startswith("-"):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "fractal-toolkit"
version = "3.1.1"
version = "3.1.2"
description = "Fractal is a scaffolding toolkit for building SOLID logic for your Python applications."
authors = ["Douwe van der Meij <douwe@karibu-online.nl>"]

Expand Down

0 comments on commit f805fd3

Please sign in to comment.