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


99
100
101
# File 'lib/hanami/action/cache/conditional_get.rb', line 99

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


105
106
107
# File 'lib/hanami/action/cache/conditional_get.rb', line 105

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


111
112
113
# File 'lib/hanami/action/cache/conditional_get.rb', line 111

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