Module: Metaractor::ContextErrors
- Defined in:
- lib/metaractor/context_errors.rb
Instance Method Summary collapse
- #add_error(message: nil, errors: nil, **args) ⇒ Object
- #add_errors(messages: [], errors: {}, **args) ⇒ Object
- #error_messages ⇒ Object
- #errors ⇒ Object
- #fail_with_error!(message: nil, errors: nil, **args) ⇒ Object
- #fail_with_errors!(messages: [], errors: {}, **args) ⇒ Object
Instance Method Details
#add_error(message: nil, errors: nil, **args) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/metaractor/context_errors.rb', line 21 def add_error(message: nil, errors: nil, **args) if .nil? add_errors(errors: errors, **args) else add_errors(messages: Array(), **args) end end |
#add_errors(messages: [], errors: {}, **args) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/metaractor/context_errors.rb', line 29 def add_errors(messages: [], errors: {}, **args) if !.empty? self.errors.add(errors: {base: }, **args) else self.errors.add(errors: errors, **args) end end |
#error_messages ⇒ Object
37 38 39 |
# File 'lib/metaractor/context_errors.rb', line 37 def errors. end |
#errors ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/metaractor/context_errors.rb', line 3 def errors if super.nil? self.errors = Metaractor::Errors.new end super end |
#fail_with_error!(message: nil, errors: nil, **args) ⇒ Object
11 12 13 14 |
# File 'lib/metaractor/context_errors.rb', line 11 def fail_with_error!(message: nil, errors: nil, **args) add_error(message: , errors: errors, **args) fail! end |
#fail_with_errors!(messages: [], errors: {}, **args) ⇒ Object
16 17 18 19 |
# File 'lib/metaractor/context_errors.rb', line 16 def fail_with_errors!(messages: [], errors: {}, **args) add_errors(messages: , errors: errors, **args) fail! end |