module WorkflowSequel
Public Instance Methods
before_validation()
click to toggle source
Calls superclass method
# File app/sequel_workflow_presistence.rb, line 16 def before_validation send( "#{self.class.workflow_column}=", current_state.to_s ) unless send( self.class.workflow_column ) super end
dataset_update( attrs )
click to toggle source
# File app/sequel_workflow_presistence.rb, line 11 def dataset_update( attrs ) @@whitelist ||= (self.columns - [:id]).freeze self.class.instance_dataset.where( id: id ).update( attrs.delete_if{|k,v| [:id, 'id'].include?(k) } ) end
load_workflow_state()
click to toggle source
# File app/sequel_workflow_presistence.rb, line 2 def load_workflow_state send( self.class.workflow_column ) end
persist_workflow_state(new_value)
click to toggle source
# File app/sequel_workflow_presistence.rb, line 6 def persist_workflow_state(new_value) send( "#{self.class.workflow_column}=", new_value ) save( changed: true, validate: false) end