Class: HTTP::Security::Headers::CacheControl

Inherits:
Object
  • Object
show all
Defined in:
lib/http/security/headers/cache_control.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CacheControl



8
9
10
11
12
# File 'lib/http/security/headers/cache_control.rb', line 8

def initialize(options={})
  @private  = options[:private]
  @max_age  = options[:max_age]
  @no_cache = options[:no_cache]
end

Instance Attribute Details

#max_ageObject (readonly)

Returns the value of attribute max_age.



6
7
8
# File 'lib/http/security/headers/cache_control.rb', line 6

def max_age
  @max_age
end

Instance Method Details

#no_cache?Boolean



18
19
20
# File 'lib/http/security/headers/cache_control.rb', line 18

def no_cache?
  !!@no_cache
end

#private?Boolean



14
15
16
# File 'lib/http/security/headers/cache_control.rb', line 14

def private?
  !!@private
end

#to_sObject



22
23
24
25
26
27
28
29
30
31
# File 'lib/http/security/headers/cache_control.rb', line 22

def to_s
  directives = []


  directives << "private"             if @private
  directives << "max-age=#{@max_age}" if @max_age
  directives << "no-cache"            if @no_cache

  return directives.join(', ')
end