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
# File 'lib/insights/api/common/error_document.rb', line 5

def add(status = 400, message)
  @status = status
  errors << {"status" => status, "detail" => message}
  self
end

#blank?Boolean

Returns:

  • (Boolean)


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

def blank?
  errors.blank?
end

#errorsObject



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

def errors
  @errors ||= []
end

#statusObject



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

def status
  @status
end

#to_hObject



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

def to_h
  {"errors" => errors}
end