docbrown/app/services/edge_cache/commentable/bust.rb
Michael Kohl b57ced5466 CacheBuster refactoring (#4766)
* Turn CacheBuster into a module

This class used no internal state, so repeatedly creating short-lived objects seems wasteful.

* Consistently use string interpolation and parenthesis

* Destructure arrays into meaningful names, formatting

* Fix request spec for internal classified listings controller

Interestingly this works when asserting directly on the module, but not on a double.
Asserting directly in the module seems sufficient for this test so the indirection
was removed.

* Turn CacheBuster into a module

This class used no internal state, so repeatedly creating short-lived objects seems wasteful.

* Fix specs after rebasing
2019-11-13 10:51:23 -05:00

24 lines
497 B
Ruby

module EdgeCache
module Commentable
class Bust
def initialize(commentable, cache_buster = CacheBuster)
@commentable = commentable
@cache_buster = cache_buster
end
def self.call(*args)
new(*args).call
end
def call
cache_buster.bust_comment(commentable)
cache_buster.bust("#{commentable.path}/comments")
commentable.index!
end
private
attr_reader :commentable, :cache_buster
end
end
end