Class: Backframe::ImageCache::Cache
- Inherits:
-
Object
- Object
- Backframe::ImageCache::Cache
- Defined in:
- lib/backframe/image_cache/lib/cache.rb
Instance Method Summary collapse
-
#initialize(filepath, conversions) ⇒ Cache
constructor
A new instance of Cache.
- #process ⇒ Object
- #test(filepath, conversions) ⇒ Object
Constructor Details
#initialize(filepath, conversions) ⇒ Cache
Returns a new instance of Cache.
9 10 11 12 |
# File 'lib/backframe/image_cache/lib/cache.rb', line 9 def initialize(filepath, conversions) @filepath = filepath @conversions = conversions end |
Instance Method Details
#process ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/backframe/image_cache/lib/cache.rb', line 14 def process begin test(filepath, conversions) rescue test(nil, conversions) end end |
#test(filepath, conversions) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/backframe/image_cache/lib/cache.rb', line 22 def test(filepath, conversions) filekey = filepath || 'default.jpg' normalized = Backframe::ImageCache::Conversions.new(conversions) key = "imagecache/#{normalized.to_s}/#{filekey}" if !redis.get(key) asset = Backframe::ImageCache::Asset.new(filepath, normalized).process upload_to_s3(asset, key) save_to_redis(key) end return OpenStruct.new(:success => true, :url => "#{Rails.application.config.cdn_url}/#{key}") end |