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

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

Instance Method Summary collapse

Instance Method Details

#load_workflow_stateObject



11
12
13
# File 'lib/workflow/adapters/active_record.rb', line 11

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.



17
18
19
20
21
22
23
24
25
# File 'lib/workflow/adapters/active_record.rb', line 17

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