event_news/lib/event_news_model/cache.rb

16 lines
429 B
Ruby

module EventNewsModel
module Cache
require 'active_support/concern'
extend ActiveSupport::Concern
included do
before_save :do_before_save
end
def do_before_save
if self.class == SubPart
EventNewsCache.where(parent_id:self.id).destroy
elsif self.class == EventNews || (self.class == Page && self.module == "event_news")
EventNewsCache.all.destroy
end
end
end
end