Class: PrettyApi::Errors::NestedErrors
- Inherits:
-
Object
- Object
- PrettyApi::Errors::NestedErrors
- Defined in:
- lib/pretty_api/errors/nested_errors.rb
Instance Method Summary collapse
-
#initialize(nested_tree:) ⇒ NestedErrors
constructor
A new instance of NestedErrors.
- #parse(record) ⇒ Object
Constructor Details
#initialize(nested_tree:) ⇒ NestedErrors
Returns a new instance of NestedErrors.
4 5 6 |
# File 'lib/pretty_api/errors/nested_errors.rb', line 4 def initialize(nested_tree:) @nested_tree = nested_tree end |
Instance Method Details
#parse(record) ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/pretty_api/errors/nested_errors.rb', line 8 def parse(record) errors = record_only_errors(record) return errors if nested_tree.blank? parse_deep_nested_errors(record, nested_tree[record.class], errors) PrettyApi::Utils::Hash.deep_compact_blank(errors) end |