Class: Hanami::Action::Cache::LastModified 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.

LastModified value object

Since:

  • 0.3.0

Instance Method Summary collapse

Constructor Details

#initialize(env, value) ⇒ LastModified

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 LastModified.

Since:

  • 0.3.0



63
64
65
# File 'lib/hanami/action/cache/conditional_get.rb', line 63

def initialize(env, value)
  @env, @value = env, value
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



69
70
71
72
73
74
# File 'lib/hanami/action/cache/conditional_get.rb', line 69

def fresh?
  return false if Hanami::Utils::Blank.blank?(modified_since)
  return false if Hanami::Utils::Blank.blank?(@value)

  Time.httpdate(modified_since).to_i >= @value.to_time.to_i
end

#headerObject

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



78
79
80
# File 'lib/hanami/action/cache/conditional_get.rb', line 78

def header
  { LAST_MODIFIED => @value.httpdate } if @value && @value.respond_to?(:httpdate)
end