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. 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
#build_accessionable(sample) ⇒ Object
134 135 136 |
# File 'lib/accession.rb', line 134 def build_accessionable(sample) Accession::Sample.new(Accession.configuration., sample) end |
#perform(sample, event_user, perform_now) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/accession.rb', line 120 def perform(sample, event_user, perform_now) return unless accessioning_enabled? return unless sample.should_be_accessioned? accessionable = build_accessionable(sample) job = SampleAccessioningJob.new(accessionable, event_user) if perform_now inline_accession_job!(job) else enqueue_accessioning_job!(job) end end |