Module: Control::Workflow

Defined in:
lib/control/workflow.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
# File 'lib/control/workflow.rb', line 4

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#current_stateObject

Get workflow current state

Returns:

  • the state object



48
49
50
# File 'lib/control/workflow.rb', line 48

def current_state
  transitions.last.to if transitions.last
end

#enabledBoolean

Checks if workflow is enabled

Returns:

  • (Boolean)


28
29
30
# File 'lib/control/workflow.rb', line 28

def enabled
  true
end

#statesArray<Class>

Get all state classes associated to this workflow

Returns:

  • (Array<Class>)


34
35
36
# File 'lib/control/workflow.rb', line 34

def states
  self.class.states
end

#transitionsArray<Transition> Also known as: history

Get all transitions.

Returns:



40
41
42
# File 'lib/control/workflow.rb', line 40

def transitions
  Control::Transition.where(:workflow_class => self.class.name, :workflow_id => self.id)
end