Class: Heel::ErrorResponse

Inherits:
Rack::Response
  • Object
show all
Defined in:
lib/heel/error_response.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_uri, body, status = 404, header = {}) ⇒ ErrorResponse

Returns a new instance of ErrorResponse.



30
31
32
33
34
# File 'lib/heel/error_response.rb', line 30

def initialize(base_uri, body, status = 404, header = {})
  super(body, status, header)
  self['Content-type'] = 'text/html'
  @base_uri = base_uri
end

Instance Attribute Details

#base_uriObject (readonly)

Returns the value of attribute base_uri.



14
15
16
# File 'lib/heel/error_response.rb', line 14

def base_uri
  @base_uri
end

Class Method Details

.homepageObject



25
26
27
# File 'lib/heel/error_response.rb', line 25

def homepage
  @homepage ||= Heel::Configuration::HOMEPAGE
end

.templateObject



21
22
23
# File 'lib/heel/error_response.rb', line 21

def template
  @template ||= ::ERB.new(File.read(template_file))
end

.template_fileObject



17
18
19
# File 'lib/heel/error_response.rb', line 17

def template_file
  @template_file ||= Heel::Configuration.data_path("error.rhtml")
end

Instance Method Details

#finishObject



36
37
38
39
40
41
# File 'lib/heel/error_response.rb', line 36

def finish
  message  = ::Rack::Utils::HTTP_STATUS_CODES[status]
  homepage = ErrorResponse.homepage

  return [ status, header.to_hash, ErrorResponse.template.result(binding) ]
end