Module: ActsAsTaggableOn::Taggable::Cache::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#acts_as_taggable_on(*args) ⇒ Object



58
59
60
61
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb', line 58

def acts_as_taggable_on(*args)
  super(*args)
  initialize_tags_cache
end

#caching_tag_list_on?(context) ⇒ Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb', line 63

def caching_tag_list_on?(context)
  column_names.include?("cached_#{context.to_s.singularize}_list")
end

#initialize_tags_cacheObject



48
49
50
51
52
53
54
55
56
# File 'lib/acts_as_taggable_on/acts_as_taggable_on/cache.rb', line 48

def initialize_tags_cache
  tag_types.map(&:to_s).each do |tag_type|
    class_eval <<-RUBY, __FILE__, __LINE__ + 1
      def self.caching_#{tag_type.singularize}_list?
        caching_tag_list_on?("#{tag_type}")
      end
    RUBY
  end
end