tmaier / workflow-sequel

Adds support for the Sequel ORM to the workflow gem
MIT License
0 stars 1 forks source link

Needs update to latest workflow #4

Open deemytch opened 5 years ago

deemytch commented 5 years ago
Bundler could not find compatible versions for gem "workflow":                                                               │
  In snapshot (Gemfile.lock):                                                                                                │
    workflow (= 2.0.2)                                                                                                       │
                                                                                                                             │
  In Gemfile:                                                                                                                │
    workflow                                                                                                                 │
                                                                                                                             │
    workflow-sequel was resolved to 0.0.1, which depends on                                                                  │
      workflow (~> 1.1.0)                                                                                                    │
tmaier commented 5 years ago

Hi @deemytch, can you propose a pull request?

tmaier commented 5 years ago

You can check out what changed at workflow-activerecord

deemytch commented 5 years ago

Excuse me, not this and next week. You can also take into this: https://github.com/geekq/workflow/issues/217 I think this path will not be trivial for me.

deemytch commented 5 years ago

I made a spike in my project for now, hope this will help you (or me in the future) to to discover the bug.

module WorkflowSequel
  def load_workflow_state
    send( self.class.workflow_column )
  end

  def persist_workflow_state(new_value)
    send( "#{self.class.workflow_column}=", new_value )
    save( changed: true, validate: false)
  end

  def dataset_update( attrs )
    self.class.instance_dataset.where( id: id ).update( attrs.delete_if{|k,v| [:id, 'id'].include?(k) } )
  end

  def before_validation
    send( "#{self.class.workflow_column}=", current_state.to_s ) unless send( self.class.workflow_column )
    super
  end

end