Class: StaticSync::Meta::Caching

Inherits:
Object
  • Object
show all
Defined in:
lib/static_sync/meta/caching.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Caching

Returns a new instance of Caching.



5
6
7
# File 'lib/static_sync/meta/caching.rb', line 5

def initialize(config)
  @config = config
end

Instance Method Details

#for(file, mime) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/static_sync/meta/caching.rb', line 9

def for(file, mime)
  meta = {}
  type = mime.sub_type
  type = mime.media_type if mime.media_type == "image"
  if @config.cache.has_key?(type)
    expiry = @config.cache[type].to_i
    meta.merge!(
      :cache_control => "public, max-age=#{expiry}"
    )
  end
  meta
end