Module: Workflow::Definition::ClassMethods
- Defined in:
- lib/workflow/definition.rb
Instance Attribute Summary collapse
-
#workflow_spec ⇒ Object
readonly
Returns the value of attribute workflow_spec.
Instance Method Summary collapse
-
#workflow { ... } ⇒ nil
Define workflow for the class.
Instance Attribute Details
#workflow_spec ⇒ Object (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.
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
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 |