Class: Memcacheable::FetchOne

Inherits:
Fetcher
  • Object
show all
Defined in:
lib/memcacheable/fetch_one.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Fetcher

#debug, #fetch, #flush

Constructor Details

#initialize(klass, id) ⇒ FetchOne

Returns a new instance of FetchOne.



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

def initialize(klass, id)
  self.klass = klass
  self.id = id  
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/memcacheable/fetch_one.rb', line 3

def id
  @id
end

#klassObject

Returns the value of attribute klass.



3
4
5
# File 'lib/memcacheable/fetch_one.rb', line 3

def klass
  @klass
end

Instance Method Details

#cache_keyObject



10
11
12
# File 'lib/memcacheable/fetch_one.rb', line 10

def cache_key
  [klass.name.downcase, id]
end

#descriptionObject



14
15
16
# File 'lib/memcacheable/fetch_one.rb', line 14

def description
  "#{klass.name.downcase} #{id}"
end

#find_on_cache_missObject



18
19
20
# File 'lib/memcacheable/fetch_one.rb', line 18

def find_on_cache_miss
  klass.find id
end