Skip to content

Commit

Permalink
feat: add extra behvaior by inheritance
Browse files Browse the repository at this point in the history
- add different value to field
- accept others types to LinkField
  • Loading branch information
Julián Cortés committed Sep 24, 2020
1 parent c4648a8 commit 6e1580c
Show file tree
Hide file tree
Showing 5 changed files with 568 additions and 228 deletions.
232 changes: 229 additions & 3 deletions nyoibo/entities/entity.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions nyoibo/entities/entity.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,13 @@ class Entity(metaclass=MetaEntity):
if field.immutable is True or field.private is True:
key = f'_{key}'
value = field.parse(value)
value = self._additional_value(key, field, value)
setattr(self, key, value)

def _additional_value(self, key, field, value):
"""additional value
This is useful if you want change the behavior
by inheritance.
"""
return value
Loading

0 comments on commit 6e1580c

Please sign in to comment.