Module: Workflow::WorkflowClassMethods
- Defined in:
- lib/workflow.rb
Instance Attribute Summary collapse
-
#workflow_spec ⇒ Object
readonly
Returns the value of attribute workflow_spec.
Instance Method Summary collapse
Instance Attribute Details
#workflow_spec ⇒ Object (readonly)
Returns the value of attribute workflow_spec.
86 87 88 |
# File 'lib/workflow.rb', line 86 def workflow_spec @workflow_spec end |
Instance Method Details
#workflow(&specification) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/workflow.rb', line 88 def workflow(&specification) @workflow_spec = Specification.new(Hash.new, &specification) @workflow_spec.states.values.each do |state| state_name = state.name module_eval do define_method "#{state_name}?" do state_name == current_state.name end end state.events.values.each do |event| event_name = event.name module_eval do define_method "#{event_name}!".to_sym do |*args| process_event!(event_name, *args) end end end end end |