Module: Workflow::WorkflowClassMethods
- Defined in:
- lib/workflow.rb
Instance Attribute Summary
-
- (Object) workflow_spec
readonly
Returns the value of attribute workflow_spec.
Instance Method Summary
Instance Attribute Details
- (Object) workflow_spec (readonly)
Returns the value of attribute workflow_spec
107 108 109 |
# File 'lib/workflow.rb', line 107 def workflow_spec @workflow_spec end |
Instance Method Details
- (Object) workflow(&specification)
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/workflow.rb', line 119 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 define_method "can_#{event_name}?" do return self.current_state.events.include? event_name end end end end end |
- (Object) workflow_column(column_name = nil)
109 110 111 112 113 114 115 116 117 |
# File 'lib/workflow.rb', line 109 def workflow_column(column_name=nil) if column_name @workflow_state_column_name = column_name.to_sym end if !@workflow_state_column_name && superclass.respond_to?(:workflow_column) @workflow_state_column_name = superclass.workflow_column end @workflow_state_column_name ||= :workflow_state end |