Value Object¶
Info: | DDD Value Object implementation. |
---|---|
Author: | Paweł Zadrożny @pawelzny <pawel.zny@gmail.com> |
Features¶
- Value object can’t be changed once created
- Two objects with the same values are considered equal
- Access to values after dot: value.my_value
- Access to values like dict: value[‘my_value’]
Documentation¶
Read full documentation on: http://vo.readthedocs.io
Quick Example¶
>>> from vo import Value
...
>>> class Book(Value):
... price = None
... title = None
... publisher = None
...
>>> book = Book(price=120, title='Python for masses', publisher='SPAM')
>>> book
Book(price=120, title='Python for masses', publisher='SPAM')
>>> book.title
'Python for masses'
>>> book['price']
120
>>> book.price = 230
Traceback (most recent call last):
File "<input>", line 1, in <module>
raise ImmutableInstanceError
vo.value.ImmutableInstanceError: Modification of Value instance is forbidden.