Modeling Leggett-Garg-inequality violation