Class: Committee::ValidationError

Inherits:
Object
  • Object
show all
Defined in:
lib/committee/validation_error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(status, id, message, request = nil) ⇒ ValidationError

Returns a new instance of ValidationError.



7
8
9
10
11
12
# File 'lib/committee/validation_error.rb', line 7

def initialize(status, id, message, request = nil)
  @status = status
  @id = id
  @message = message
  @request = request
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/committee/validation_error.rb', line 5

def id
  @id
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/committee/validation_error.rb', line 5

def message
  @message
end

#requestObject (readonly)

Returns the value of attribute request.



5
6
7
# File 'lib/committee/validation_error.rb', line 5

def request
  @request
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/committee/validation_error.rb', line 5

def status
  @status
end

Instance Method Details

#error_bodyObject



14
15
16
# File 'lib/committee/validation_error.rb', line 14

def error_body
  { id: id, message: message }
end

#renderObject



18
19
20
21
22
23
24
# File 'lib/committee/validation_error.rb', line 18

def render
  [
    status,
    { "Content-Type" => "application/json" },
    [JSON.generate(error_body)]
  ]
end