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

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

Instance Method Summary collapse

Instance Method Details

#acts_as_taggable_on(*args) ⇒ Object


65
66
67
68
# File 'lib/acts_as_taggable_on/taggable/cache.rb', line 65

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

#caching_tag_list_on?(context) ⇒ Boolean

Returns:

  • (Boolean)

70
71
72
# File 'lib/acts_as_taggable_on/taggable/cache.rb', line 70

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

#initialize_tags_cacheObject


55
56
57
58
59
60
61
62
63
# File 'lib/acts_as_taggable_on/taggable/cache.rb', line 55

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