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.
128 129 130 |
# File 'lib/workflow.rb', line 128 def workflow_spec @workflow_spec end |
Instance Method Details
#workflow(&specification) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/workflow.rb', line 140 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 |
#workflow_column(column_name = nil) ⇒ Object
130 131 132 133 134 135 136 137 138 |
# File 'lib/workflow.rb', line 130 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 |