Source code for towers.core.utils

#!/usr/bin/env python
# -*- coding: latin-1 -*-
#
# @module towers.core.utils
# @version 0.1
# @copyright (c) 2017-present Francis Horsman.

import abc


[docs]class Serializable(object): """ A mixin which shows that a class is serializable. """ @abc.abstractmethod
[docs] def to_json(self): """ Return a json serializable representation of this instance. :rtype: object """ raise NotImplementedError()
@abc.abstractmethod
[docs] def from_json(self, d): """ Return a class instance from a json serializable representation. :param str|dict d: The json or decoded-json from which to create a new instance from. """ raise NotImplementedError()