Module: Hanami::Action::Cache::CacheControl Private

Defined in:
lib/hanami/action/cache/cache_control.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Module with Cache-Control logic

Since:

  • 0.3.0

Defined Under Namespace

Modules: ClassMethods Classes: Directives

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ 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.

Since:

  • 0.3.0



13
14
15
16
17
18
# File 'lib/hanami/action/cache/cache_control.rb', line 13

def self.included(base)
  base.class_eval do
    extend ClassMethods
    @cache_control_directives = nil
  end
end

Instance Method Details

#finish(_, res, _) ⇒ 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.

Finalize the response including default cache headers into the response

See Also:

  • Hanami::Action#finish

Since:

  • 0.3.0



46
47
48
49
50
51
52
# File 'lib/hanami/action/cache/cache_control.rb', line 46

def finish(_, res, _)
  unless res.headers.include?(Action::CACHE_CONTROL)
    res.headers.merge!(self.class.cache_control_directives.headers)
  end

  super
end