Module: ActsAsTaggableOn::Taggable::Cache::Columns

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

Instance Method Summary collapse

Instance Method Details

#columnsObject

ActiveRecord::Base.columns makes a database connection and caches the

calculated columns hash for the record as @columns.  Since we don't
want to add caching methods until we confirm the presence of a
caching column, and we don't want to force opening a database
connection when the class is loaded, here we intercept and cache
the call to :columns as @acts_as_taggable_on_cache_columns
to mimic the underlying behavior.  While processing this first
call to columns, we do the caching column check and dynamically add
the class and instance methods
FIXME: this method cannot compile in rubinius


20
21
22
23
24
25
26
# File 'lib/acts_as_taggable_on/taggable/cache.rb', line 20

def columns
  @acts_as_taggable_on_cache_columns ||= begin
    db_columns = super
    _add_tags_caching_methods if _has_tags_cache_columns?(db_columns)
    db_columns
  end
end

#reset_column_informationObject



28
29
30
31
# File 'lib/acts_as_taggable_on/taggable/cache.rb', line 28

def reset_column_information
  super
  @acts_as_taggable_on_cache_columns = nil
end