Skip to content

Commit 68ae29c

Browse files
ilaifMidnighter
andcommitted
feat: add hydration and interactions
Co-authored-by: Midnighter <[email protected]>
1 parent 595f28f commit 68ae29c

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/structurizr/model/person.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
from pydantic import Field
2020

2121
from .location import Location
22+
from .relationship import Relationship
2223
from .static_structure_element import StaticStructureElement, StaticStructureElementIO
24+
from .tags import Tags
2325

2426

2527
__all__ = ("PersonIO", "Person")
@@ -35,7 +37,7 @@ class PersonIO(StaticStructureElementIO):
3537
"""
3638

3739
location: Location = Field(
38-
Location.Unspecified, description="The location of this person."
40+
default=Location.Unspecified, description="The location of this person."
3941
)
4042

4143

@@ -48,20 +50,22 @@ class Person(StaticStructureElement):
4850
4951
"""
5052

51-
location: Location = Field(
52-
Location.Unspecified, description="The location of this person."
53-
)
54-
5553
def __init__(self, *, location: Location = Location.Unspecified, **kwargs) -> None:
5654
""""""
5755
super().__init__(**kwargs)
5856
self.location = location
5957

58+
self.tags.add(Tags.PERSON)
59+
6060
@classmethod
6161
def hydrate(cls, person_io: PersonIO) -> "Person":
6262
""""""
63-
return cls(name=person_io.name, description=person_io.description)
64-
65-
def interacts_with(self):
66-
# TODO
67-
pass
63+
return cls(
64+
name=person_io.name,
65+
location=person_io.location,
66+
description=person_io.description,
67+
relationships=map(Relationship.hydrate, person_io.relationships),
68+
)
69+
70+
def interacts_with(self, destination: "Person", description: str, **kwargs):
71+
return self.uses(destination=destination, description=description, **kwargs)

0 commit comments

Comments
 (0)