Sha256: b947ea2a8b234e7c71b6160545551497afd0710305f23e0297f88484449a10fe

Contents?: true

Size: 358 Bytes

Versions: 2

Compression:

Stored size: 358 Bytes

Contents

class ReviewSweeper < ActionController::Caching::Sweeper
  observe Review
  def after_create(review)
    expire_cache_for(review)
  end

  def after_update(review)
    expire_cache_for(review)
  end

  def after_destroy(review)
    expire_cache_for(review)
  end
  
  private
  
  def expire_cache_for(review)
    review.product.recalculate_rating
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_reviews-0.50.1 app/models/review_sweeper.rb
spree_reviews-0.50.0 app/models/review_sweeper.rb