Module: MotherBrain::Job::States Private

Defined in:
lib/mb/job/states.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

A mixin to provide helper functions around the state of a Job, JobRecord, or JobTicket. The helper functions are based on states set by StateMachine

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#stateObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



6
7
8
# File 'lib/mb/job/states.rb', line 6

def state
  @state
end

Instance Method Details

#completed?Boolean Also known as: finished?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If a job has succeeded or failed it considered completed

Returns:

  • (Boolean)


11
12
13
# File 'lib/mb/job/states.rb', line 11

def completed?
  self.success? || self.failure?
end

#failure?Boolean Also known as: failed?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If a job has failed it is considered a failure

Returns:

  • (Boolean)


19
20
21
# File 'lib/mb/job/states.rb', line 19

def failure?
  self.state == :failure
end

#pending?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If a job has not begun and is in the pending state it is considered pending

Returns:

  • (Boolean)


27
28
29
# File 'lib/mb/job/states.rb', line 27

def pending?
  self.state == :pending
end

#running?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If a job has begun running and is in the running state it is considered running

Returns:

  • (Boolean)


34
35
36
# File 'lib/mb/job/states.rb', line 34

def running?
  self.state == :running
end

#success?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

If a job has succeeded it is considered a success

Returns:

  • (Boolean)


41
42
43
# File 'lib/mb/job/states.rb', line 41

def success?
  self.state == :success
end