Class: Insights::API::Common::ErrorDocument

Inherits:
Object
  • Object
show all
Defined in:
lib/insights/api/common/error_document.rb

Instance Method Summary collapse

Instance Method Details

#add(status = 400, message) ⇒ Object



5
6
7
8
9
10
# File 'lib/insights/api/common/error_document.rb', line 5

def add(status = 400, message)
  @status = status
  safe_message = message.to_s.encode('UTF-8', :invalid => :replace, :undef => :replace)
  errors << {"status" => status, "detail" => safe_message}
  self
end

#blank?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/insights/api/common/error_document.rb', line 20

def blank?
  errors.blank?
end

#errorsObject



12
13
14
# File 'lib/insights/api/common/error_document.rb', line 12

def errors
  @errors ||= []
end

#statusObject



16
17
18
# File 'lib/insights/api/common/error_document.rb', line 16

def status
  @status
end

#to_hObject



24
25
26
# File 'lib/insights/api/common/error_document.rb', line 24

def to_h
  {"errors" => errors}
end