about summary refs log tree commit diff
path: root/app/models/concerns/cacheable.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/concerns/cacheable.rb')
-rw-r--r--app/models/concerns/cacheable.rb15
1 files changed, 15 insertions, 0 deletions
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