From a21bcac9e156d8c40fe7c15c62ac71a901091cc5 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 30 Nov 2016 15:57:56 +0100 Subject: Further abstract caching for includes --- app/models/concerns/cacheable.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 app/models/concerns/cacheable.rb (limited to 'app/models/concerns') diff --git a/app/models/concerns/cacheable.rb b/app/models/concerns/cacheable.rb new file mode 100644 index 000000000..cd0167048 --- /dev/null +++ b/app/models/concerns/cacheable.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Cacheable + extend ActiveSupport::Concern + + class_methods do + def cache_associated(*associations) + @cache_associated = associations + end + end + + included do + scope :with_includes, -> { includes(@cache_associated) } + end +end -- cgit