Module: Workflow::Adapter::ActiveRecord::InstanceMethods
- Defined in:
- lib/workflow/adapters/active_record.rb
Instance Method Summary collapse
- #load_workflow_state ⇒ Object
-
#persist_workflow_state(new_value) ⇒ Object
On transition the new workflow state is immediately saved in the database, if configured to do so.
Instance Method Details
#load_workflow_state ⇒ Object
11 12 13 |
# File 'lib/workflow/adapters/active_record.rb', line 11 def load_workflow_state read_attribute(self.class.workflow_column)&.to_sym end |
#persist_workflow_state(new_value) ⇒ Object
On transition the new workflow state is immediately saved in the database, if configured to do so.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/workflow/adapters/active_record.rb', line 17 def persist_workflow_state(new_value) # Rails 3.1 or newer if persisted? && Workflow.config.persist_workflow_state_immediately attrs = {self.class.workflow_column => new_value} if Workflow.config.touch_on_update_column attrs[:updated_at] = DateTime.now end update_columns attrs else self[self.class.workflow_column] = new_value end end |