Skip to content

Commit

Permalink
Added some information to the read me about using Mongoid and Moped
Browse files Browse the repository at this point in the history
  • Loading branch information
msaspence committed Apr 23, 2014
1 parent b44562c commit 35afb83
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,27 @@ A lock has an owner. Mongo::Lock defaults to using an owner id of HOSTNAME:PID:T

Mongo::Lock makes no effort to help configure the MongoDB connection - that's
what the Mongo driver is for, you can use either Moped or the Mongo Ruby Driver.
If you are using Mongoid you want to be using the Moped driver. Mongo::Lock will
If you are using Mongoid'll you want to be using the Moped driver. Mongo::Lock will
automatically choose the right driver for the collection you provide and raise an
error if you try and mix them.

```ruby
Mongo::Lock.configure collection: Mongo::Connection.new("localhost").db("somedb").collection("locks")
```

Or using Mongoid:
Or using Moped:

```ruby
session = Moped::Session.new([ "127.0.0.1:27017" ])
session.use 'locks_db'
Mongo::Lock.configure collection: session[:locks]
```

Or if your session is already set up with Mongoid:

```ruby
Mongo::Lock.configure collection: Mongoid.session(:default)[:locks]
```

You can add multiple collections with a hash that can be referenced later using symbols:

Expand Down

0 comments on commit 35afb83

Please sign in to comment.