Class: HttpObjects::Headers::Directives::Cache
- Inherits:
-
HttpObjects::Hash
- Object
- Hash
- HttpObjects::Hash
- HttpObjects::Headers::Directives::Cache
- Defined in:
- lib/http_objects/headers/directives/cache.rb
Overview
Cache-Control = “Cache-Control” “:” 1#cache-directive
cache-directive = cache-request-directive
| cache-response-directive
cache-request-directive =
"no-cache" ; Section 14.9.1
| "no-store" ; Section 14.9.2
| "max-age" "=" delta-seconds ; Section 14.9.3, 14.9.4
| "max-stale" [ "=" delta-seconds ] ; Section 14.9.3
| "min-fresh" "=" delta-seconds ; Section 14.9.3
| "no-transform" ; Section 14.9.5
| "only-if-cached" ; Section 14.9.4
| cache-extension ; Section 14.9.6
cache-response-directive =
"public" ; Section 14.9.1
| "private" [ "=" <"> 1#field-name <"> ] ; Section 14.9.1
| "no-cache" [ "=" <"> 1#field-name <"> ]; Section 14.9.1
| "no-store" ; Section 14.9.2
| "no-transform" ; Section 14.9.5
| "must-revalidate" ; Section 14.9.4
| "proxy-revalidate" ; Section 14.9.4
| "max-age" "=" delta-seconds ; Section 14.9.3
| "s-maxage" "=" delta-seconds ; Section 14.9.3
| cache-extension ; Section 14.9.6
cache-extension = token [ “=” ( token | quoted-string ) ]
Constant Summary collapse
- TOKEN =
token [ “=” ( token | quoted-string ) ]
/([^,=]+)(?:=\s*(?:\"([^\"]*)\"|\'([^\']*)\'|([^,]*)))?/
Constants inherited from HttpObjects::Hash
HttpObjects::Hash::MethodCreator
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value) ⇒ Cache
constructor
A new instance of Cache.
Methods inherited from HttpObjects::Hash
#[], #[]=, add_attribute, new, #to_s
Methods included from Attributes
#attributes, #register_attribute
Constructor Details
#initialize(value) ⇒ Cache
Returns a new instance of Cache.
72 73 74 75 |
# File 'lib/http_objects/headers/directives/cache.rb', line 72 def initialize(value) @raw = value @value = value.is_a?(Array)? value.first : value.to_s end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
45 46 47 |
# File 'lib/http_objects/headers/directives/cache.rb', line 45 def raw @raw end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
45 46 47 |
# File 'lib/http_objects/headers/directives/cache.rb', line 45 def value @value end |
Class Method Details
.parse(value) ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/http_objects/headers/directives/cache.rb', line 60 def self.parse(value) cache = self.new(value) cache.value.scan(TOKEN).each do |key, v1, v2, v3| key = key.strip next if key.length.zero? key.downcase! key_value = (v1 || v2 || v3).to_s cache[key] = key_value.strip end cache end |