Class: Dragonfly::Response

Inherits:
Object show all
Defined in:
lib/dragonfly/response.rb

Constant Summary collapse

DEFAULT_FILENAME =
proc{

Instance Method Summary collapse

Constructor Details

#initialize(job, env) ⇒ Response

Returns a new instance of Response.



13
14
15
16
# File 'lib/dragonfly/response.rb', line 13

def initialize(job, env)
  @job, @env = job, env
  @app = @job.app
end

Instance Method Details

#to_responseObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dragonfly/response.rb', line 18

def to_response
  if etag_matches?
    # Not Modified
    [304, cache_headers, []]
  else
    # Success
    [200, success_headers.merge(cache_headers), job.result]
  end
rescue DataStorage::DataNotFound => e
  [404, {"Content-Type" => 'text/plain'}, [e.message]]
end