Class: Backframe::ImageCache::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/backframe/image_cache/image_cache.rb

Instance Method Summary collapse

Instance Method Details

#asset(filepath, conversions) ⇒ Object



11
12
13
# File 'lib/backframe/image_cache/image_cache.rb', line 11

def asset(filepath, conversions)
  Backframe::ImageCache::Asset.new(filepath, conversions).process
end

#cached(filepath, conversions) ⇒ Object



15
16
17
# File 'lib/backframe/image_cache/image_cache.rb', line 15

def cached(filepath, conversions)
  Backframe::ImageCache::Cache.new(filepath, conversions).process
end

#cdn_root(conversions) ⇒ Object



33
34
35
36
# File 'lib/backframe/image_cache/image_cache.rb', line 33

def cdn_root(conversions)
  root = Rails.application.config.root_url
  (conversions.key?(:secure) && !conversions[:secure]) ? root.gsub('https', 'http') : root
end

#cdn_url(filepath, conversions) ⇒ Object



29
30
31
# File 'lib/backframe/image_cache/image_cache.rb', line 29

def cdn_url(filepath, conversions)
  Rails.application.config.cdn_url + path(filepath, conversions)
end

#path(filepath, conversions) ⇒ Object



19
20
21
22
23
# File 'lib/backframe/image_cache/image_cache.rb', line 19

def path(filepath, conversions)
  string = Backframe::ImageCache::Conversions.new(conversions).to_s
  filekey = filepath || 'default.jpg'
  "/imagecache/#{string}/#{filekey}"
end

#url(filepath, conversions) ⇒ Object



25
26
27
# File 'lib/backframe/image_cache/image_cache.rb', line 25

def url(filepath, conversions)
  cdn_root(conversions) + path(filepath, conversions)
end