Using instance_eval instead of direct access to object attributes to expose the generated counts, because it caused warnings in Rails >= 3.2.