Module: Cacheable::Keys::InstanceKeys

Defined in:
lib/cacheable/keys.rb

Instance Method Summary collapse

Instance Method Details

#belong_association_cache_key(name, polymorphic = nil) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/cacheable/keys.rb', line 38

def belong_association_cache_key(name, polymorphic=nil)
  name = name.to_s if name.is_a?(Symbol)
  if polymorphic
    "#{self.send("#{name}_type").tableize}/#{self.send("#{name}_id")}"
  else
    "#{name.tableize}/#{self.send(name + "_id")}"
  end
end

#have_association_cache_key(name) ⇒ Object



47
48
49
# File 'lib/cacheable/keys.rb', line 47

def have_association_cache_key(name)
  "#{model_cache_key}/association/#{name}"
end

#method_cache_key(meth) ⇒ Object



34
35
36
# File 'lib/cacheable/keys.rb', line 34

def method_cache_key(meth)
  "#{model_cache_key}/method/#{meth}"
end

#model_cache_keyObject



30
31
32
# File 'lib/cacheable/keys.rb', line 30

def model_cache_key
  "#{self.class.name.tableize}/#{self.id.to_i}"
end