Class: LcpRuby::BatchActions::RestoreService
- Inherits:
-
BaseService
- Object
- BaseService
- LcpRuby::BatchActions::RestoreService
- Defined in:
- lib/lcp_ruby/batch_actions/restore_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#batch_operation, #current_user, #evaluator, #model_definition, #progress, #records
Instance Method Summary collapse
Methods inherited from BaseService
Constructor Details
This class inherits a constructor from LcpRuby::BatchActions::BaseService
Instance Method Details
#call ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/lcp_ruby/batch_actions/restore_service.rb', line 4 def call restored = 0 denied = 0 each_record do |record, index| progress&.call(index) if evaluator.can_for_record?(:update, record) record.undiscard! log_item(record, "updated") restored += 1 else log_item(record, "skipped", error_details: { reason: "permission_denied" }) denied += 1 end end finalize_batch_operation(restored, denied, 0) Actions::Result.new( success: true, message: ("restored", restored, denied), redirect_to: nil, data: batch_operation ? { batch_operation_id: batch_operation.id } : nil, errors: [] ) end |