Class: Logistics::Core::AdditionalDocumentService
- Inherits:
-
BaseService
- Object
- BaseService
- Logistics::Core::AdditionalDocumentService
- Defined in:
- app/services/logistics/core/additional_document_service.rb
Instance Method Summary collapse
- #bulk_delete(ids) ⇒ Object
- #bulk_save(payload) ⇒ Object
- #bulk_update(payload) ⇒ Object
- #get_additional_documents(entity, rec_id) ⇒ Object
- #get_lookup_values(entity) ⇒ Object
Methods inherited from BaseService
Instance Method Details
#bulk_delete(ids) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/services/logistics/core/additional_document_service.rb', line 41 def bulk_delete(ids) error = '' success = true begin AdditionalDocument.where(:id => ids).destroy_all rescue => e success = false error = 'Could not delete all records' end [success, error] end |
#bulk_save(payload) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/services/logistics/core/additional_document_service.rb', line 14 def bulk_save(payload) error = '' success = true begin AdditionalDocument.create!(payload) rescue => e success = false error = 'Some records could not be saved!' end [success, error] end |
#bulk_update(payload) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/services/logistics/core/additional_document_service.rb', line 26 def bulk_update(payload) errors = [] success = true payload.each do |p| ad = AdditionalDocument.find(p[:id]) begin ad.update!(p) rescue => e success = false error << ad.id end end [success, errors] end |
#get_additional_documents(entity, rec_id) ⇒ Object
9 10 11 12 |
# File 'app/services/logistics/core/additional_document_service.rb', line 9 def get_additional_documents(entity, rec_id) clazz = entity.constantize clazz.find(rec_id).additional_documents end |
#get_lookup_values(entity) ⇒ Object
4 5 6 7 |
# File 'app/services/logistics/core/additional_document_service.rb', line 4 def get_lookup_values(entity) clazz = entity.constantize clazz.all end |