'Add a new mapping'

def add_mapping(self, data, name=None):

    from .mappings import DocumentObjectField
    from .mappings import NestedObject
    from .mappings import ObjectField
    if isinstance(data, (DocumentObjectField, ObjectField, NestedObject)):
        self.mappings[data.name] = data.as_dict()
        return
    if name:
        self.mappings[name] = data
        return
        if isinstance(data, dict):
            self.mappings.update(data)
        elif isinstance(data, list):
            for d in data:
                if isinstance(d, dict):
                    self.mappings.update(d)
                elif isinstance(d, DocumentObjectField):
                    self.mappings[d.name] = d.as_dict()
                else:
                    (name, data) = d
                    self.add_mapping(data, name)
