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.3.2"

Instance Method Summary collapse

Instance Method Details

#cache_association_name(name) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/cache_associations.rb', line 95

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



105
106
107
108
109
# File 'lib/cache_associations.rb', line 105

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

  Rails.cache.delete(cache_name)
end