Module: Workflow::ClassMethods
- Defined in:
- lib/workflow.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.
-
#workflow_column(column_name = nil) ⇒ void
Instructs Workflow which column to use to persist workflow state.
Instance Attribute Details
#workflow_spec ⇒ Object (readonly)
Returns the value of attribute workflow_spec.
190 191 192 |
# File 'lib/workflow.rb', line 190 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
239 240 241 |
# File 'lib/workflow.rb', line 239 def workflow(&specification) assign_workflow Specification.new(Hash.new, &specification) end |
#workflow_column(column_name = nil) ⇒ void
This method returns an undefined value.
Instructs Workflow which column to use to persist workflow state.
196 197 198 199 200 201 202 203 204 |
# File 'lib/workflow.rb', line 196 def workflow_column(column_name=nil) if column_name @workflow_state_column_name = column_name.to_sym end if !instance_variable_defined?('@workflow_state_column_name') && superclass.respond_to?(:workflow_column) @workflow_state_column_name = superclass.workflow_column end @workflow_state_column_name ||= :workflow_state end |