Module: Workflow::Definition
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#current_state ⇒ State
Returns a state object representing the current workflow state.
-
#workflow_spec ⇒ Specification
The specification for this object.
Instance Method Details
#current_state ⇒ State
Returns a state object representing the current workflow state.
9 10 11 12 13 |
# File 'lib/workflow/definition.rb', line 9 def current_state loaded_state = load_workflow_state res = workflow_spec.states.find { |t| t.name == loaded_state.to_sym } if loaded_state res || workflow_spec.initial_state end |
#workflow_spec ⇒ Specification
The specification for this object. Could be set on a singleton for the object, on the object's class, Or else on a superclass of the object.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/workflow/definition.rb', line 19 def workflow_spec # check the singleton class first class << self return workflow_spec if workflow_spec end c = self.class # using a simple loop instead of class_inheritable_accessor to avoid # dependency on Rails' ActiveSupport c = c.superclass until c.workflow_spec || !(c.include? Workflow) c.workflow_spec end |