Class: ConciseErrors::Formatter

Inherits:
Object
  • Object
show all
Defined in:
lib/concise_errors/formatter.rb

Overview

Builds the compact error payload for browser responses.

Constant Summary collapse

OMITTED_SUFFIX =
"... %<count>d more lines omitted"

Instance Method Summary collapse

Constructor Details

#initialize(wrapper, request, configuration) ⇒ Formatter

Returns a new instance of Formatter.



12
13
14
15
16
# File 'lib/concise_errors/formatter.rb', line 12

def initialize(wrapper, request, configuration)
  @wrapper = wrapper
  @request = request
  @configuration = configuration
end

Instance Method Details

#bodyObject



18
19
20
# File 'lib/concise_errors/formatter.rb', line 18

def body
  response_format == :html ? html_payload : text_payload
end

#content_typeObject



22
23
24
# File 'lib/concise_errors/formatter.rb', line 22

def content_type
  response_format == :html ? "text/html" : "text/plain"
end