class Heel::ErrorResponse

Attributes

base_uri[R]

Public Class Methods

homepage() click to toggle source
# File lib/heel/error_response.rb, line 24
def homepage
  @homepage ||= Heel::Configuration::HOMEPAGE
end
new(base_uri, body, status = 404, header = {}) click to toggle source
# File lib/heel/error_response.rb, line 29
def initialize(base_uri, body, status = 404, header = {})
  header    = header.merge( "Content-Type" => 'text/html' )
  @response = Rack::Response.new('', status, header )
  @base_uri = base_uri
end
template() click to toggle source
# File lib/heel/error_response.rb, line 20
def template
  @template ||= ::ERB.new(File.read(template_file))
end
template_file() click to toggle source
# File lib/heel/error_response.rb, line 16
def template_file
  @template_file ||= Heel::Configuration.data_path("error.rhtml")
end

Public Instance Methods

finish() click to toggle source
# File lib/heel/error_response.rb, line 35
def finish
  template_vars = TemplateVars.new( :status   => @response.status,
                                    :message  => Rack::Utils::HTTP_STATUS_CODES[@response.status],
                                    :base_uri => base_uri,
                                    :homepage => ErrorResponse.homepage )

  content  = ErrorResponse.template.result( template_vars.binding_for_template )
  @response.write( content )
  return @response.finish
end