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
>>> value = Value(test=True, some_text="I am some text string")
>>> value == value
True
>>> value_clone = Value(some_text="I am some text string", test=True)
>>> value == value_clone
True
>>> value is value_clone
False
>>> value_truth = Value(purpose_of_life=42)
>>> value == value_truth
False
>>> value_truth.purpose_of_life
42
>>> value_truth['purpose_of_life']
42