Class: GraphitiErrors::InvalidRequest::Serializer
- Inherits:
-
Object
- Object
- GraphitiErrors::InvalidRequest::Serializer
- Defined in:
- lib/graphiti_errors/invalid_request/serializer.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
-
#initialize(errors) ⇒ Serializer
constructor
A new instance of Serializer.
- #rendered_errors ⇒ Object
Constructor Details
#initialize(errors) ⇒ Serializer
Returns a new instance of Serializer.
5 6 7 |
# File 'lib/graphiti_errors/invalid_request/serializer.rb', line 5 def initialize(errors) @errors = errors end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
4 5 6 |
# File 'lib/graphiti_errors/invalid_request/serializer.rb', line 4 def errors @errors end |
Instance Method Details
#rendered_errors ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/graphiti_errors/invalid_request/serializer.rb', line 9 def rendered_errors errors_payload = [] errors.details.each_pair do |attribute, att_errors| att_errors.each_with_index do |error, idx| code = error[:error] = errors.[attribute][idx] errors_payload << { code: "bad_request", status: "400", title: "Request Error", detail: errors.(attribute, ), source: { pointer: attribute.to_s.tr(".", "/").gsub(/\[(\d+)\]/, '/\1'), }, meta: { attribute: attribute, message: , code: code, }, } end end errors_payload end |