module WorkflowActiverecord::InstanceMethods
Public Instance Methods
load_workflow_state()
click to toggle source
# File lib/workflow-activerecord.rb, line 14 def load_workflow_state read_attribute(self.class.workflow_column) end
persist_workflow_state(new_value)
click to toggle source
On transition the new workflow state is immediately saved in the database.
# File lib/workflow-activerecord.rb, line 20 def persist_workflow_state(new_value) # Rails 3.1 or newer update_column self.class.workflow_column, new_value end
Private Instance Methods
write_initial_state()
click to toggle source
Motivation: even if NULL is stored in the workflow_state database column, the current_state is correctly recognized in the Ruby code. The problem arises when you want to SELECT records filtering by the value of initial state. That's why it is important to save the string with the name of the initial state in all the new records.
# File lib/workflow-activerecord.rb, line 32 def write_initial_state write_attribute self.class.workflow_column, current_state.to_s end