Class: Hanami::Action::Cache::ConditionalGet Private
- Inherits:
-
Object
- Object
- Hanami::Action::Cache::ConditionalGet
- Defined in:
- lib/hanami/action/cache/conditional_get.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class responsible to determine if a given request is fresh based on IF_NONE_MATCH and IF_MODIFIED_SINCE headers
Instance Method Summary collapse
- #fresh? ⇒ Boolean private
- #headers ⇒ Object private
-
#initialize(env, options) ⇒ ConditionalGet
constructor
private
A new instance of ConditionalGet.
Constructor Details
#initialize(env, options) ⇒ ConditionalGet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ConditionalGet.
83 84 85 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 83 def initialize(env, ) @validations = [ETag.new(env, [:etag]), LastModified.new(env, [:last_modified])] end |
Instance Method Details
#fresh? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
89 90 91 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 89 def fresh? yield if @validations.any?(&:fresh?) end |
#headers ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 95 def headers @validations.map(&:header).compact.reduce({}, :merge) end |