Module: ShafClient::HypertextCacheStrategy
- Included in:
- ShafClient
- Defined in:
- lib/shaf_client/hypertext_cache_strategy.rb
Constant Summary collapse
- AVAILABLE_CACHE_STRATEGIES =
[ CACHE_STRATEGY_NO_CACHE = :no_cache, CACHE_STRATEGY_EMBEDDED = :use_embedded, CACHE_STRATEGY_FETCH_HEADERS = :fetch_headers ]
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.cacheable?(strategy) ⇒ Boolean
10 11 12 |
# File 'lib/shaf_client/hypertext_cache_strategy.rb', line 10 def cacheable?(strategy) [CACHE_STRATEGY_EMBEDDED, CACHE_STRATEGY_FETCH_HEADERS].include? strategy end |
.default_http_status ⇒ Object
18 19 20 |
# File 'lib/shaf_client/hypertext_cache_strategy.rb', line 18 def default_http_status 203 end |
.fetch_headers?(strategy) ⇒ Boolean
14 15 16 |
# File 'lib/shaf_client/hypertext_cache_strategy.rb', line 14 def fetch_headers?(strategy) CACHE_STRATEGY_FETCH_HEADERS == strategy end |
Instance Method Details
#default_hypertext_cache_strategy ⇒ Object
23 24 25 |
# File 'lib/shaf_client/hypertext_cache_strategy.rb', line 23 def default_hypertext_cache_strategy @__default_hypertext_cache_strategy ||= CACHE_STRATEGY_EMBEDDED end |
#default_hypertext_cache_strategy=(strategy) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/shaf_client/hypertext_cache_strategy.rb', line 27 def default_hypertext_cache_strategy=(strategy) unless __valid_cache? strategy raise Error, " Unsupported hypertext cache strategy: \#{strategy}\n Possible strategies are: \#{AVAILABLE_CACHE_STRATEGIES.join(', ')}\n ERR\n end\n @__default_hypertext_cache_strategy = value\nend\n" |