Module: Workflow::Definition::ClassMethods

Defined in:
lib/workflow/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#workflow_specObject (readonly)

Returns the value of attribute workflow_spec.



33
34
35
# File 'lib/workflow/definition.rb', line 33

def workflow_spec
  @workflow_spec
end

Instance Method Details

#workflow { ... } ⇒ nil

Define workflow for the class.

Workflow definition takes place inside the yielded block. ~~~ruby

class Article include Workflow workflow do state :new do event :submit, :transitions_to => :awaiting_review end state :awaiting_review do event :review, :transitions_to => :being_reviewed end state :being_reviewed do event :accept, :transitions_to => :accepted event :reject, :transitions_to => :rejected end state :accepted state :rejected end end

~~~

Yields:

  • [] Specification of workflow. Example below and in README.markdown

Returns:

  • (nil)

See Also:

  • Specification::state
  • Specification::event


67
68
69
70
# File 'lib/workflow/definition.rb', line 67

def workflow(&specification)
  @workflow_spec = Specification.new({}, &specification)
  HelperMethodConfigurator.new(@workflow_spec, self).configure!
end