lib/heel/error_response.rb in heel-2.0.0 vs lib/heel/error_response.rb in heel-3.0.0

- old
+ new

@@ -1,17 +1,16 @@ #-- -# Copyright (c) 2007, 2008 Jeremy Hinegardner -# All rights reserved. Licensed under the BSD license. See LICENSE for details +# Copyright (c) 2007 - 2013 Jeremy Hinegardner +# All rights reserved. Licensed under the BSD license. See LICENSE for details #++ -require 'heel' require 'rack' require 'erb' module Heel - class ErrorResponse < ::Rack::Response + class ErrorResponse attr_reader :base_uri class << self def template_file @@ -26,18 +25,20 @@ @homepage ||= Heel::Configuration::HOMEPAGE end end def initialize(base_uri, body, status = 404, header = {}) - super(body, status, header) - self['Content-type'] = 'text/html' + header = header.merge( "Content-Type" => 'text/html' ) + @response = Rack::Response.new( body, status, header ) @base_uri = base_uri end def finish - message = ::Rack::Utils::HTTP_STATUS_CODES[status] - homepage = ErrorResponse.homepage - - return [ status, header.to_hash, ErrorResponse.template.result(binding) ] + status = @response.status # for the template + message = ::Rack::Utils::HTTP_STATUS_CODES[status] # for the template + homepage = ErrorResponse.homepage # for the template + content = ErrorResponse.template.result( binding ) + @response.write( content ) + return @response.finish end end end