Class: Middleman::S3Sync::BrowserCachePolicy
- Inherits:
-
Object
- Object
- Middleman::S3Sync::BrowserCachePolicy
- Defined in:
- lib/middleman/s3_sync/caching_policy.rb
Instance Attribute Summary collapse
-
#policies ⇒ Object
Returns the value of attribute policies.
Instance Method Summary collapse
- #cache_control ⇒ Object
- #expires ⇒ Object
-
#initialize(options = {}) ⇒ BrowserCachePolicy
constructor
A new instance of BrowserCachePolicy.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ BrowserCachePolicy
Returns a new instance of BrowserCachePolicy.
27 28 29 |
# File 'lib/middleman/s3_sync/caching_policy.rb', line 27 def initialize( = {}) @policies = Map.from_hash() end |
Instance Attribute Details
#policies ⇒ Object
Returns the value of attribute policies.
25 26 27 |
# File 'lib/middleman/s3_sync/caching_policy.rb', line 25 def policies @policies end |
Instance Method Details
#cache_control ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# 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 ⇒ Object
52 53 54 55 56 |
# 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 ⇒ Object
48 49 50 |
# File 'lib/middleman/s3_sync/caching_policy.rb', line 48 def to_s cache_control end |