Skip to content

Conversation

@damncabbage
Copy link

This PR:

  • Makes the ActiveRecord adapter more self-contained (by having it handle its own inclusion, extension and before_validation hook setup).
  • Has Workflow look for a workflow_adapter class method first before going on to include ActiveRecord or Remodel adapters.

From the included documentation change:

Other adapters (such as a custom ActiveRecord plugin) can be selected by adding a workflow_adapter class method, eg.

class Example
  def self.workflow_adapter
    MyCustomAdapter
  end
  include Workflow
  # ...
end

(The above will include MyCustomAdapter instead of Workflow::Adapter::ActiveRecord.)

@damncabbage
Copy link
Author

Where am I going with this? I have an app-specific ActiveRecord adapter I'm working on (to handle record-locking to avoid race conditions, among other things), but the auto-inclusion in lib/workflow.rb prevents me from using it without forking the project entirely.

(I'm happy to have this closed if you don't feel it fits with the direction of the project.)

@geekq
Copy link
Owner

geekq commented Jul 29, 2014

yes, this is the direction I would like to go too - enable custom AR persistence.

Will review after my computerless ;-) holiday - in a week...

@damncabbage
Copy link
Author

Got it; thanks. :)

geekq added a commit that referenced this pull request Aug 5, 2014
Adds ability to select different adapters via a `workflow_adapter` class method.
@geekq geekq merged commit 90db308 into geekq:master Aug 5, 2014
@geekq
Copy link
Owner

geekq commented Aug 5, 2014

This is exactly the way I would implement the possibility for different persistent behaviours, e.g. persist new workflow state immediately on bang-method call (default) vs. later on save call. But never found time for that ;-) - thank you very much!

Also solves #77 - custom ActiveRecord adapter (persisting on save call) would help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants