Class: Memcacheable::FetchBelongsTo
Instance Attribute Summary
#association, #object
Instance Method Summary
collapse
#cache_key, #class_name, #description, #initialize
Methods inherited from Fetcher
#debug, #fetch, #flush
Instance Method Details
#fetchable? ⇒ Boolean
3
4
5
|
# File 'lib/memcacheable/fetch_belongs_to.rb', line 3
def fetchable?
klass.respond_to?(:fetch)
end
|
#find_on_cache_miss ⇒ Object
7
8
9
10
|
# File 'lib/memcacheable/fetch_belongs_to.rb', line 7
def find_on_cache_miss
id = object.send "#{association}_id"
fetchable? ? klass.fetch(id) : object.send(association) rescue nil
end
|
#klass ⇒ Object
12
13
14
|
# File 'lib/memcacheable/fetch_belongs_to.rb', line 12
def klass
@klass ||= association.to_s.camelize.constantize
end
|