Sha256: 3d3978817ee82c7fd8473b7bbb037997b462f964ea87c306a05f5f84030c8620
Contents?: true
Size: 734 Bytes
Versions: 2
Compression:
Stored size: 734 Bytes
Contents
if Hancock.mongoid? module Hancock::Cacheable extend ActiveSupport::Concern included do field :cache_keys_str, type: String, default: -> { default_cache_keys.join("\n") } def self.default_cache_keys [] end def default_cache_keys self.class.default_cache_keys end def cache_keys cache_keys_str.split(/\s+/).map { |k| k.strip }.reject { |k| k.blank? } end field :perform_caching, type: Boolean, default: true after_save :clear_cache after_destroy :clear_cache def clear_cache if perform_caching cache_keys.each do |k| Rails.cache.delete(k) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hancock_cms-2.0.0 | app/models/concerns/hancock/cacheable.rb |
hancock_cms-1.0.0 | app/models/concerns/hancock/cacheable.rb |