Class: BulkAction
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- BulkAction
- Defined in:
- app/models/bulk_action.rb
Overview
BulkAction
Direct Known Subclasses
BulkActions::ChangePublicationState, BulkActions::DeleteThumbnails, BulkActions::DraftDocument, BulkActions::HarvestThumbnails, BulkActions::UnpublishDocument
Instance Method Summary collapse
- #check_run_state ⇒ Object
- #collect_documents ⇒ Object
- #revert! ⇒ Object
- #run! ⇒ Object
- #state_machine ⇒ Object
Instance Method Details
#check_run_state ⇒ Object
42 43 44 45 46 47 |
# File 'app/models/bulk_action.rb', line 42 def check_run_state nil if state_machine.current_state == "complete" # @TODO / background job for collecting documents # state_machine.transition_to!(:complete) if documents.in_state(:queued).blank? end |
#collect_documents ⇒ Object
54 55 56 57 58 59 60 61 62 |
# File 'app/models/bulk_action.rb', line 54 def collect_documents cgi = CGI.unescape(scope) uri = URI.parse(cgi) if uri.path.include?("fetch") fetch_documents(uri) else api_documents(uri) end end |
#revert! ⇒ Object
49 50 51 52 |
# File 'app/models/bulk_action.rb', line 49 def revert! # Queue Revert Job BulkActionRevertJob.perform_later(self) end |
#run! ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/bulk_action.rb', line 31 def run! # @TODO: guard this call for validation? # Queue Job BulkActionRunJob.perform_later(self) # Capture State # state_machine.transition_to!(:imported) # save end |
#state_machine ⇒ Object
27 28 29 |
# File 'app/models/bulk_action.rb', line 27 def state_machine @state_machine ||= BulkActionStateMachine.new(self, transition_class: BulkActionTransition) end |