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



83
84
85
# File 'lib/hanami/action/cache/conditional_get.rb', line 83

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



89
90
91
# File 'lib/hanami/action/cache/conditional_get.rb', line 89

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



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

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