README.md in counter-cache-0.0.2 vs README.md in counter-cache-0.1.0
- old
+ new
@@ -107,9 +107,23 @@
relation_class_name: "User",
method: :calculate_posts_count, # This is a method on the user.
end
```
+#### To increment dynamically:
+
+```ruby
+class Review
+ include Counter::Cache
+
+ counter_cache_on column: :reviews_sum,
+ relation: :product,
+ relation_class_name: "Product",
+ increment_by: ->(review) { review.score },
+ method: :recalculate_reviews_sum, # This is a method on the product.
+end
+```
+
#### To control when recalculation happens:
```ruby
class Post
include Counter::Cache