Condition added for counter cache.

Code is modified for

1. Make it work on mongoid 4.0.x, ruby 2.1.0 and rails 4.x. Code is modified to work on mongoid versions from 2.x to 4.x  
2. Added condition : Counter will be incremented or decremented if condition is true. (eg. increment counter only after comment is published)
3. Added required test cases for this change in code.