Class: Hanami::Action::Cache::ConditionalGet Private

Inherits:
Object
  • Object
show all
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

Since:

  • 0.3.0

Instance Method Summary collapse

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.

Since:

  • 0.3.0



96
97
98
# File 'lib/hanami/action/cache/conditional_get.rb', line 96

def initialize(env, options)
  @validations = [ ETag.new(env, options[:etag]), LastModified.new(env, options[: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.

Returns:

  • (Boolean)

Since:

  • 0.3.0



102
103
104
# File 'lib/hanami/action/cache/conditional_get.rb', line 102

def fresh?
  yield if @validations.any?(&:fresh?)
end

#headersObject

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.

Since:

  • 0.3.0



108
109
110
# File 'lib/hanami/action/cache/conditional_get.rb', line 108

def headers
  @validations.map(&:header).compact.reduce Hash.new, :merge
end