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.
96 97 98 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 96 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.
102 103 104 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 102 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.
108 109 110 |
# File 'lib/hanami/action/cache/conditional_get.rb', line 108 def headers @validations.map(&:header).compact.reduce Hash.new, :merge end |