Module: SemanticallyTaggable::Taggable::Cache

Defined in:
lib/semantically_taggable/semantically_taggable/cache.rb

Overview

TODO: reintroduce caching support?

Defined Under Namespace

Modules: ClassMethods, InstanceMethods

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/semantically_taggable/semantically_taggable/cache.rb', line 4

def self.included(base)
  # Skip adding caching capabilities if table not exists or no cache columns exist
  return unless base.table_exists? && base.scheme_names.any? {
      |scheme_name| base.column_names.include?("cached_#{scheme_name.to_s.singularize}_list") }

  base.send :include, SemanticallyTaggable::Taggable::Cache::InstanceMethods
  base.extend SemanticallyTaggable::Taggable::Cache::ClassMethods
  
  base.class_eval do
    before_save :save_cached_tag_list        
  end
  
  base.initialize_semantically_taggable_cache
end