cacheable.rb 333 B

12345678910111213141516
  1. # frozen_string_literal: true
  2. module Cacheable
  3. extend ActiveSupport::Concern
  4. class_methods do
  5. def cache_associated(*associations)
  6. @cache_associated = associations
  7. end
  8. end
  9. included do
  10. scope :with_includes, -> { includes(@cache_associated) }
  11. scope :cache_ids, -> { select(:id, :updated_at) }
  12. end
  13. end