Class: Facades::Helpers::Frontend::ImageCache

Inherits:
Object
  • Object
show all
Defined in:
lib/facades/helpers/frontend.rb

Overview

Caches placeholder image data based on a md5 hash.

Instance Method Summary collapse

Instance Method Details

#get(args) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/facades/helpers/frontend.rb', line 22

def get(args)
  hash    = ::Digest::MD5.hexdigest("#{args.join('|')}")
  return cache[hash] if cache[hash].present?
  
  width   = args.shift
  height  = (args.shift || width)
  color   = (args.shift || '#cccccc')
  text    = args.shift
  
  cache[hash] = generate_png(width, height, color, text)
end