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



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

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

    # The validations that the pipeline & batch are correct
    validates :pipeline, presence: true

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

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

Instance Method Details

#has_item_limit?Boolean Also known as: has_limit?

Returns:

  • (Boolean)


21
22
23
# File 'app/models/batch/pipeline_behaviour.rb', line 21

def has_item_limit?
  item_limit.present?
end

#last_completed_taskObject



26
27
28
# File 'app/models/batch/pipeline_behaviour.rb', line 26

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