Module: Batch::PipelineBehaviour

Included in:
Batch
Defined in:
app/models/batch/pipeline_behaviour.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/models/batch/pipeline_behaviour.rb', line 2

def self.included(base)
  base.class_eval do
    # The associations with the pipeline
    belongs_to :pipeline
    delegate :workflow, :item_limit, :multiplexed?, to: :pipeline
    delegate :tasks, to: :workflow

    # The validations that the pipeline & batch are correct
    validates_presence_of :pipeline

    # Validation of some of the batch information is left to the pipeline that it belongs to
    validate do |record|
      record.pipeline.validation_of_batch(record) if record.pipeline.present?
    end

    # The batch requires positions on it's requests if the pipeline does
    delegate :requires_position?, to: :pipeline

    # Ensure that the batch is valid to be marked as completed
    validate(if: :completed?) do |record|
      record.pipeline.validation_of_batch_for_completion(record)
    end
  end
end

Instance Method Details

#has_item_limit?Boolean Also known as: has_limit?

Returns:

  • (Boolean)

33
34
35
# File 'app/models/batch/pipeline_behaviour.rb', line 33

def has_item_limit?
  item_limit.present?
end

#last_completed_taskObject


38
39
40
# File 'app/models/batch/pipeline_behaviour.rb', line 38

def last_completed_task
  pipeline.workflow.tasks.order(:sorted).where(id: completed_task_ids).last unless complete_events.empty?
end

#show_actions?Boolean

Returns:

  • (Boolean)

27
28
29
30
31
# File 'app/models/batch/pipeline_behaviour.rb', line 27

def show_actions?
  return true if pipeline.is_a?(CherrypickForPulldownPipeline)

  !released?
end