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) ⇒ ValidationError

Returns a new instance of ValidationError.



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

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/committee/validation_error.rb', line 3

def id
  @id
end

#messageObject (readonly)

Returns the value of attribute message.



3
4
5
# File 'lib/committee/validation_error.rb', line 3

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



3
4
5
# File 'lib/committee/validation_error.rb', line 3

def status
  @status
end

Instance Method Details

#error_bodyObject



11
12
13
# File 'lib/committee/validation_error.rb', line 11

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

#renderObject



15
16
17
18
19
20
21
# File 'lib/committee/validation_error.rb', line 15

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