Module: MuchRails::DestroyService::ValidationErrors
- Defined in:
- lib/much-rails/destroy_service.rb
Class Method Summary collapse
- .add(exception_class, &block) ⇒ Object
- .exception_classes ⇒ Object
- .result_for(ex) ⇒ Object
- .service_validation_errors ⇒ Object
Class Method Details
.add(exception_class, &block) ⇒ Object
31 32 33 |
# File 'lib/much-rails/destroy_service.rb', line 31 def self.add(exception_class, &block) service_validation_errors.add(exception_class, &block) end |
.exception_classes ⇒ Object
35 36 37 |
# File 'lib/much-rails/destroy_service.rb', line 35 def self.exception_classes service_validation_errors.exception_classes end |
.result_for(ex) ⇒ Object
39 40 41 |
# File 'lib/much-rails/destroy_service.rb', line 39 def self.result_for(ex) service_validation_errors.result_for(ex) end |
.service_validation_errors ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/much-rails/destroy_service.rb', line 43 def self.service_validation_errors @service_validation_errors ||= MuchRails::ServiceValidationErrors .new .tap do |e| e.add(MuchRails::Records::DestructionInvalid) do |ex| MuchRails::DestroyService::FailureResult.new( record: ex.record, exception: ex, validation_errors: ex.errors.to_h, validation_error_messages: ex..to_a, ) end e.add(MuchRails::InvalidError) do |ex| MuchRails::SaveService::FailureResult.new( exception: ex, validation_errors: ex.errors, validation_error_messages: ex., ) end end end |