Sha256: 26a778eec99f9c70e3e60e5ede35af7c8d60c8a5dc55a105e4ecc046f9df08da

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

module CloudCrowd
  
  # Adds named scopes and query methods for every CloudCrowd status to
  # both Jobs and WorkUnits.
  module ModelStatus
    
    def self.included(klass)
      
      klass.class_eval do
        # Note that COMPLETE and INCOMPLETE are unions of other states.
        scope 'processing', -> { where( :status => PROCESSING )}
        scope 'succeeded',  -> { where( :status => SUCCEEDED  )}
        scope 'failed',     -> { where( :status => FAILED     )}
        scope 'splitting',  -> { where( :status => SPLITTING  )}
        scope 'merging',    -> { where( :status => MERGING    )}
        scope 'complete',   -> { where( :status => COMPLETE   )}
        scope 'incomplete', -> { where( :status => INCOMPLETE )}
      end
      
    end
    
    def processing?;  self.status == PROCESSING;          end
    def succeeded?;   self.status == SUCCEEDED;           end
    def failed?;      self.status == FAILED;              end
    def splitting?;   self.status == SPLITTING;           end
    def merging?;     self.status == MERGING;             end
    def complete?;    COMPLETE.include?(self.status);     end
    def incomplete?;  INCOMPLETE.include?(self.status);   end
    
    # Get the displayable status name of the model's status code.
    def display_status
      CloudCrowd.display_status(self.status)
    end
    
  end
end

require 'cloud_crowd/models/job'
require 'cloud_crowd/models/node_record'
require 'cloud_crowd/models/work_unit'
require 'cloud_crowd/models/black_listed_action'

module CloudCrowd
  MODELS = [Job, NodeRecord, WorkUnit, BlackListedAction]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cloud-crowd-0.7.6 lib/cloud_crowd/models.rb