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

+ (Object) included(klass)



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

- (Boolean) complete?

Returns:

  • (Boolean)


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

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

- (Object) display_status

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

- (Boolean) failed?

Returns:

  • (Boolean)


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

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

- (Boolean) incomplete?

Returns:

  • (Boolean)


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

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

- (Boolean) merging?

Returns:

  • (Boolean)


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

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

- (Boolean) processing?

Returns:

  • (Boolean)


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

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

- (Boolean) splitting?

Returns:

  • (Boolean)


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

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

- (Boolean) succeeded?

Returns:

  • (Boolean)


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

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