Module: CloudCrowd::ModelStatus

Included in:
Job, WorkUnit
Defined in:
lib/cloud_crowd/models.rb

Overview

Adds named scopes and query methods for every CloudCrowd status to both Jobs and WorkUnits.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cloud_crowd/models.rb', line 7

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

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


27
# File 'lib/cloud_crowd/models.rb', line 27

def complete?;    COMPLETE.include?(self.status);     end

#display_statusObject

Get the displayable status name of the model’s status code.



31
32
33
# File 'lib/cloud_crowd/models.rb', line 31

def display_status
  CloudCrowd.display_status(self.status)
end

#failed?Boolean

Returns:

  • (Boolean)


24
# File 'lib/cloud_crowd/models.rb', line 24

def failed?;      self.status == FAILED;              end

#incomplete?Boolean

Returns:

  • (Boolean)


28
# File 'lib/cloud_crowd/models.rb', line 28

def incomplete?;  INCOMPLETE.include?(self.status);   end

#merging?Boolean

Returns:

  • (Boolean)


26
# File 'lib/cloud_crowd/models.rb', line 26

def merging?;     self.status == MERGING;             end

#processing?Boolean

Returns:

  • (Boolean)


22
# File 'lib/cloud_crowd/models.rb', line 22

def processing?;  self.status == PROCESSING;          end

#splitting?Boolean

Returns:

  • (Boolean)


25
# File 'lib/cloud_crowd/models.rb', line 25

def splitting?;   self.status == SPLITTING;           end

#succeeded?Boolean

Returns:

  • (Boolean)


23
# File 'lib/cloud_crowd/models.rb', line 23

def succeeded?;   self.status == SUCCEEDED;           end