How to deal with an emotionally damaged person?

How much is too much when dealing with a loved one that has deep emotional damage? That may be preventing them from loving you at their full potential? Or maybe they're back and forth about how they truly feel about love and has a hard time expressing it when times get dark for them?

When they have so much love for you one week and then the next, like a flip of a switch, they lash out and are mentally/emotionally abusive to you, how many times can you be there for someone, comfort them, give them advice, let them know they're not alone.. just to get treated like dirt