Class: Memcacheable::FetchBelongsTo

Inherits:
FetchAssociation show all
Defined in:
lib/memcacheable/fetch_belongs_to.rb

Instance Attribute Summary

Attributes inherited from FetchAssociation

#association, #object

Instance Method Summary collapse

Methods inherited from FetchAssociation

#cache_key, #class_name, #description, #initialize

Methods inherited from Fetcher

#debug, #fetch, #flush

Constructor Details

This class inherits a constructor from Memcacheable::FetchAssociation

Instance Method Details

#find_on_cache_missObject



4
5
6
7
8
# File 'lib/memcacheable/fetch_belongs_to.rb', line 4

def find_on_cache_miss
  klass = association.to_s.camelize.constantize
  id = object.send "#{association}_id"
  klass.respond_to?(:fetch) ? klass.fetch(id) : klass.find(id) rescue nil
end