Class: Accession::SampleAccessioning
- Inherits:
-
Object
- Object
- Accession::SampleAccessioning
- Includes:
- AccessionHelper
- Defined in:
- lib/accession.rb
Overview
Wrapper for sample accessioning with error handling and job management. Allows accessioning to be triggered from anywhere in the application. Sample and user data are passed by ID to ensure the latest data is used when the job run is performed. Encapsulates logic for validation, synchronous or asynchronous job execution, and supports private helper methods for internal workflow.
Note: does not include permission checks - these are Rails based and should be in the appropriate controller.
Instance Method Summary collapse
Methods included from AccessionHelper
#accessioning_enabled?, #permitted_to_accession?
Instance Method Details
#perform(sample, event_user, perform_now) ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/accession.rb', line 143 def perform(sample, event_user, perform_now) return unless accessioning_enabled? return unless sample.should_be_accessioned? sample_id = sample.id user_id = event_user.id job = SampleAccessioningJob.new(sample_id, user_id) if perform_now inline_accession_job!(job) else enqueue_accessioning_job!(job) end end |