Class: Rack::AcornCache::CacheControlHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/acorn_cache/cache_control_header.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header_string = "") ⇒ CacheControlHeader

Returns a new instance of CacheControlHeader.



8
9
10
11
# File 'lib/acorn_cache/cache_control_header.rb', line 8

def initialize(header_string = "")
  return unless header_string && !header_string.empty?
  set_directive_instance_variables!(header_string)
end

Instance Attribute Details

#max_ageObject

Returns the value of attribute max_age.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def max_age
  @max_age
end

#max_freshObject

Returns the value of attribute max_fresh.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def max_fresh
  @max_fresh
end

#max_staleObject Also known as: max_stale?

Returns the value of attribute max_stale.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def max_stale
  @max_stale
end

#must_revalidateObject Also known as: must_revalidate?

Returns the value of attribute must_revalidate.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def must_revalidate
  @must_revalidate
end

#no_cacheObject Also known as: no_cache?

Returns the value of attribute no_cache.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def no_cache
  @no_cache
end

#no_storeObject Also known as: no_store?

Returns the value of attribute no_store.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def no_store
  @no_store
end

#privateObject Also known as: private?

Returns the value of attribute private.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def private
  @private
end

#s_maxageObject

Returns the value of attribute s_maxage.



5
6
7
# File 'lib/acorn_cache/cache_control_header.rb', line 5

def s_maxage
  @s_maxage
end

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
# File 'lib/acorn_cache/cache_control_header.rb', line 19

def to_s
  instance_variables.map do |ivar|
    directive = ivar.to_s.sub("@", "").sub("_", "-")
    value = instance_variable_get(ivar)
    next directive if value == true
    next unless value
    "#{directive}=#{value}"
  end.compact.sort.join(", ")
end