Public API

See also

Check out Examples derived from real and fully tested source code.

class vo.value.Value(**kwargs)[source]

Basic implementation of DDD immutable Value Object.

Implementation provides:

  • Immutability of once created object
  • Comparison of two objects
  • Conversion to other data types
Param:Any key=value pairs.
to_dict() → collections.OrderedDict[source]

Dump all values to OrderedDict.

All keys are sorted in ascending direction. Dump does not include hash and checksum.

Returns:dict with values
Return type:collections.OrderedDict
to_json() → str[source]

Dump values to JSON.

Feed for JSON comes from .to_dict() method.

Returns:JSON string.
Return type:str
to_bytes() → bytes[source]

Dump values to bytes.

Feed for byte string comes from .to_json() method.

Returns:byte string
Return type:bytes
exception vo.value.ImmutableInstanceError(message: str = None)[source]

Raised on any attempt to modify values in Value object.

Parameters:message (str) – Optional message.
message = 'Modification of Value instance is forbidden.'