Class: Rack::PageCaching::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/page_caching/response.rb

Instance Method Summary collapse

Constructor Details

#initialize(response, env) ⇒ Response

Returns a new instance of Response.



6
7
8
# File 'lib/rack/page_caching/response.rb', line 6

def initialize(response, env)
  @response, @env = response, env
end

Instance Method Details

#bodyObject



18
19
20
# File 'lib/rack/page_caching/response.rb', line 18

def body
  @response[2]
end

#cacheable?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/rack/page_caching/response.rb', line 10

def cacheable?
  perform_caching? && caching_allowed?
end

#content_typeObject



22
23
24
# File 'lib/rack/page_caching/response.rb', line 22

def content_type
  @response[1]['Content-Type'].split(';').first
end

#gzip_levelObject



26
27
28
# File 'lib/rack/page_caching/response.rb', line 26

def gzip_level
  @env['rack.page_caching.compression'].to_i if @env['rack.page_caching.compression']
end

#hostObject



30
31
32
# File 'lib/rack/page_caching/response.rb', line 30

def host
  request.host
end

#pathObject



14
15
16
# File 'lib/rack/page_caching/response.rb', line 14

def path
  @path ||= request.path
end