Module: Cacheable::Keys::ClassKeys

Defined in:
lib/cacheable/keys.rb

Instance Method Summary collapse

Instance Method Details

#all_attribute_cache_key(attribute, value) ⇒ Object



15
16
17
# File 'lib/cacheable/keys.rb', line 15

def all_attribute_cache_key(attribute, value)
  "#{self.base_class.name.tableize}/attribute/#{attribute}/all/#{URI.escape(value.to_s)}"
end

#attribute_cache_key(attribute, value) ⇒ Object



11
12
13
# File 'lib/cacheable/keys.rb', line 11

def attribute_cache_key(attribute, value)
  "#{self.base_class.name.tableize}/attribute/#{attribute}/#{URI.escape(value.to_s)}"
end

#class_method_cache_key(meth, *args) ⇒ Object



19
20
21
22
23
24
# File 'lib/cacheable/keys.rb', line 19

def class_method_cache_key(meth, *args)
  key = "#{self.base_class.name.tableize}/class_method/#{meth}"
  args.flatten!
  key += "/#{args.join('+')}" if args.any?
  return key
end

#instance_cache_key(param) ⇒ Object



26
27
28
# File 'lib/cacheable/keys.rb', line 26

def instance_cache_key(param)
  "#{self.base_class.name.tableize}/#{param}"
end