Skip to content

adeelraza/workflow_on_mongoid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

About workflow_on_mongoid

workflow_on_mongoid lets you use the Workflow gem with your Mongoid documents to add state machine functionality.

How to use it

In your Gemfile, instead of

gem 'workflow'

do

gem 'workflow_on_mongoid'

That is all. Now you can use Workflow with your Mongoid documents. Of course, you can still continue to use Workflow with ActiveRecord, Remodel and plain objects. All that workflow_on_mongoid does is to add Mongoid support. You can use all the features of Workflow with Mongoid models, including reflection of events & states, transition hooks, support for inherited models, etc. Just refer to the Workflow docs.

Versioning

The version numbers of workflow_on_mongoid match the latest supported version of Workflow . The current version is 0.7.0 .

Example

class MongoidImage
  include Mongoid::Document

  field :title
  field :status

  include Workflow

  workflow_column :status

  workflow do
    state :unconverted do
      event :convert, :transitions_to => :converted
    end
    state :converted
  end
end

See the tests for Mongoid for more examples.

Tests

I’ve included all the tests from the original workflow gem and added comprehensive tests for Mongoid support, which is now as well-tested as ActiveRecord support. Including the existing tests ensures that workflow_on_mongoid implements support for Mongoid documents without breaking anything.

Project Info

workflow_on_mongoid is hosted on Github: github.com/bowsersenior/workflow_on_mongoid . It’s a tiny project, but your contributions, forkings, comments and feedback are definitely appreciated.

Copyright © 2010 Mani Tadayon, released under the MIT License

About

Use workflow with your Mongoid documents

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published