Sha256: 8b43f72464c200e4bc14bd4495a2aa4e35624eeb8ee42311c6d033672d15c040

Contents?: true

Size: 355 Bytes

Versions: 5

Compression:

Stored size: 355 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

5 entries across 5 versions & 1 rubygems

Version Path
spree_reviews_rating-0.70.7.1 app/models/review_sweeper.rb
spree_reviews_rating-0.70.7 app/models/review_sweeper.rb
spree_reviews_rating-0.70.6.1 app/models/review_sweeper.rb
spree_reviews_rating-0.70.6 app/models/review_sweeper.rb
spree_reviews_rating-0.70.5 app/models/review_sweeper.rb