Module: OscMacheteRails::Workflow::StatusMethods
- Defined in:
- lib/osc_machete_rails/workflow.rb
Overview
depends on jobs_active_record_relation being defined
Instance Method Summary collapse
-
#status ⇒ OSC::Machete::Status
Reduce the jobs to a single OSC::Machete:Status value.
Instance Method Details
#status ⇒ OSC::Machete::Status
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#+.
240 241 242 243 |
# 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 |