class Middleman::S3Sync::BrowserCachePolicy

Attributes

policies[RW]

Public Class Methods

new(options = {}) click to toggle source
# File lib/middleman/s3_sync/caching_policy.rb, line 27
def initialize(options = {})
  @policies = Map.from_hash(options)
end

Public Instance Methods

cache_control() click to toggle source
# File lib/middleman/s3_sync/caching_policy.rb, line 31
def cache_control
  policy = []
  policy << "max-age=#{policies.max_age}" if policies.has_key?(:max_age)
  policy << "s-maxage=#{policies.s_maxage}" if policies.has_key?(:s_maxage)
  policy << "public" if policies.fetch(:public, false)
  policy << "private" if policies.fetch(:private, false)
  policy << "no-cache" if policies.fetch(:no_cache, false)
  policy << "no-store" if policies.fetch(:no_store, false)
  policy << "must-revalidate" if policies.fetch(:must_revalidate, false)
  policy << "proxy-revalidate" if policies.fetch(:proxy_revalidate, false)
  if policy.empty?
    nil
  else
    policy.join(", ")
  end
end
expires() click to toggle source
# File lib/middleman/s3_sync/caching_policy.rb, line 52
def expires
  if expiration = policies.fetch(:expires, nil)
    CGI.rfc1123_date(expiration)
  end
end
to_s() click to toggle source
# File lib/middleman/s3_sync/caching_policy.rb, line 48
def to_s
  cache_control
end