Module: Workflow::Adapter::ActiveRecord::InstanceMethods

Defined in:
lib/workflow/adapters/active_record.rb

Instance Method Summary collapse

Instance Method Details

#load_workflow_stateObject



5
6
7
# File 'lib/workflow/adapters/active_record.rb', line 5

def load_workflow_state
  read_attribute(self.class.workflow_column)
end

#persist_workflow_state(new_value) ⇒ Object

On transition the new workflow state is immediately saved in the database.



11
12
13
14
15
16
17
18
19
# File 'lib/workflow/adapters/active_record.rb', line 11

def persist_workflow_state(new_value)
  if self.respond_to? :update_column
    # Rails 3.1 or newer
    update_column self.class.workflow_column, new_value
  else
    # older Rails; beware of side effect: other (pending) attribute changes will be persisted too
    update_attribute self.class.workflow_column, new_value
  end
end