Sha256: 0e0ae2f56898ba55d7ff9aaca2a7c4ac4b06ac3eef7bdb295777d02a46df27e5

Contents?: true

Size: 1.49 KB

Versions: 28

Compression:

Stored size: 1.49 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.
        named_scope 'processing', :conditions => {:status => PROCESSING}
        named_scope 'succeeded',  :conditions => {:status => SUCCEEDED}
        named_scope 'failed',     :conditions => {:status => FAILED}
        named_scope 'splitting',  :conditions => {:status => SPLITTING}
        named_scope 'merging',    :conditions => {:status => MERGING}
        named_scope 'complete',   :conditions => {:status => COMPLETE}
        named_scope 'incomplete', :conditions => {: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'

Version data entries

28 entries across 28 versions & 3 rubygems

Version Path
documentcloud-cloud-crowd-0.1.1 lib/cloud_crowd/models.rb
documentcloud-cloud-crowd-0.2.0 lib/cloud_crowd/models.rb
documentcloud-cloud-crowd-0.2.1 lib/cloud_crowd/models.rb
documentcloud-cloud-crowd-0.2.2 lib/cloud_crowd/models.rb
documentcloud-cloud-crowd-0.2.3 lib/cloud_crowd/models.rb
cloud-crowd-0.6.2 lib/cloud_crowd/models.rb
cloud-crowd-0.6.1 lib/cloud_crowd/models.rb
cloud-crowd-0.6.0 lib/cloud_crowd/models.rb
cloud-crowd-0.5.2 lib/cloud_crowd/models.rb
cloud-crowd-0.5.0 lib/cloud_crowd/models.rb
cloud-crowd-0.4.1 lib/cloud_crowd/models.rb
cloud-crowd-0.4.0 lib/cloud_crowd/models.rb
mooktakim-cloud-crowd-0.3.5 lib/cloud_crowd/models.rb
mooktakim-cloud-crowd-0.3.4 lib/cloud_crowd/models.rb
cloud-crowd-0.3.3 lib/cloud_crowd/models.rb
cloud-crowd-0.3.2 lib/cloud_crowd/models.rb
cloud-crowd-0.3.1 lib/cloud_crowd/models.rb
cloud-crowd-0.3.0 lib/cloud_crowd/models.rb
cloud-crowd-0.2.9 lib/cloud_crowd/models.rb
cloud-crowd-0.2.8 lib/cloud_crowd/models.rb