Class: EasyTalk::SchemaErrorsMapper
- Inherits:
-
Object
- Object
- EasyTalk::SchemaErrorsMapper
- Defined in:
- lib/easy_talk/schema_errors_mapper.rb
Instance Method Summary collapse
- #errors ⇒ Object
-
#initialize(errors) ⇒ SchemaErrorsMapper
constructor
A new instance of SchemaErrorsMapper.
Constructor Details
#initialize(errors) ⇒ SchemaErrorsMapper
Returns a new instance of SchemaErrorsMapper.
5 6 7 |
# File 'lib/easy_talk/schema_errors_mapper.rb', line 5 def initialize(errors) @errors = errors.to_a end |
Instance Method Details
#errors ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/easy_talk/schema_errors_mapper.rb', line 9 def errors @errors.each_with_object({}) do |error, hash| if error['data_pointer'].present? key = error['data_pointer'].split('/').compact_blank.join('.') hash[key] = error['error'] else error['details']['missing_keys'].each do |missing_key| = "#{error['error'].split(':').first}: #{missing_key}" hash[missing_key] = end end end end |