Module: CacheAssociations

Extended by:
ActiveSupport::Concern
Defined in:
lib/cache_associations.rb,
lib/cache_associations/version.rb

Constant Summary collapse

UndefinedAssociationError =
Class.new(StandardError)
VERSION =
"0.2.1"

Instance Method Summary collapse

Instance Method Details

#cache_association_name(name) ⇒ Object



76
77
78
79
80
81
82
83
84
# File 'lib/cache_associations.rb', line 76

def cache_association_name(name)
  if !!cache_name_block = self.class.cache_name_block(name)
    instance_exec(&cache_name_block)
  elsif self.class.has_cache_association?(name)
    default_cache_name(name)
  else
    nil
  end
end

#clear_caching_on_association(name) ⇒ Object



86
87
88
89
90
# File 'lib/cache_associations.rb', line 86

def clear_caching_on_association(name)
  return nil if !!cache_name = cache_association_name(name)

  Rails.cache.delete(cache_name)
end