Subrogation is the assignment to an insurer by terms of the policy or by law, after payment of a loss, of the rights of the insured to recover the amount of the loss from one legally liable for it.