about summary refs log tree commit diff
path: root/app/models/concerns
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:57:56 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-30 15:57:56 +0100
commita21bcac9e156d8c40fe7c15c62ac71a901091cc5 (patch)
treeb02405fbe4fc288bfc74525c1eddcef1a86d9444 /app/models/concerns
parent356d3874ebd79573a8da58e2ac76eaa4612cec16 (diff)
Further abstract caching for includes
Diffstat (limited to 'app/models/concerns')
-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