module OscMacheteRails::Workflow::StatusMethods
depends on jobs_active_record_relation being defined
Public Instance Methods
status()
click to toggle source
Reduce the jobs to a single OSC::Machete
:Status value
Assumes ‘jobs_active_record_relation` is a Statusable
ActiveRecord
model. Get array of status values (one for each job) and then add them together to get one value. OSC::Machete::Status#+ is overridden to return the highest precendent status value when adding two together.
FIXME: it might be clearer in code to use ‘max` instead of `+` i.e. statuses.reduce(&:max) and rename OSC::Machete::Status#+.
@return [OSC::Machete::Status] a single value representing the status
# File lib/osc_machete_rails/workflow.rb, line 240 def status statuses = jobs_active_record_relation.to_a.map(&:status) statuses.empty? ? OSC::Machete::Status.not_submitted : statuses.reduce(&:+) end