Class: Accession::SampleAccessioning

Inherits:
Object
  • Object
show all
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.

Returns:

  • (void)

Raises:

Instance Method Summary collapse

Methods included from AccessionHelper

#accessioning_enabled?, #permitted_to_accession?

Instance Method Details

#build_accessionable(sample) ⇒ Object



151
152
153
# File 'lib/accession.rb', line 151

def build_accessionable(sample)
  Accession::Sample.new(Accession.configuration.tags, sample)
end

#perform(sample, event_user, perform_now) ⇒ Object



137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/accession.rb', line 137

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