Module: TaliaCore::Workflow::WorkflowMacro
- Defined in:
- lib/talia_core/workflow.rb
Instance Method Summary collapse
-
#workflow_machine(opts) ⇒ Object
Configuration options are.
Instance Method Details
#workflow_machine(opts) ⇒ Object
Configuration options are
-
column
- specifies the column name to use for keeping the state (default: state) -
property
- specifies the column name to use for keeping the property of current state (default: state_properties) -
initial
- specifies an initial state for newly created objects (required)
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/talia_core/workflow.rb', line 128 def workflow_machine(opts) self.extend(ClassMethods) raise NoInitialState unless opts[:initial] write_inheritable_attribute :states, {} write_inheritable_attribute :initial_state, opts[:initial] write_inheritable_attribute :initial_state_properties, opts[:initial_properties] || {} write_inheritable_attribute :transition_table, {} write_inheritable_attribute :event_table, {} write_inheritable_attribute :state_column, opts[:column] || 'state' write_inheritable_attribute :state_properties_column, opts[:properties] || 'state_properties' class_inheritable_reader :initial_state class_inheritable_reader :initial_state_properties class_inheritable_reader :state_column class_inheritable_reader :state_properties_column class_inheritable_reader :transition_table class_inheritable_reader :event_table self.send(:include, TaliaCore::Workflow::InstanceMethods) before_create :set_initial_state, :set_initial_state_properties after_create :run_initial_state_actions end |