'Generically associate `item` with `associate_with` based on `foreign_key_name`.'

def associate(self, associate_with, item, foreign_key_name=None):

    foreign_key_name = (foreign_key_name or self.foreign_key_name)
    setattr(associate_with, foreign_key_name, item)
    return item
