Permalink
Browse files

Update readme and examples.

  • Loading branch information...
1 parent e7f625f commit 2b03470c25dd87a4ee8afc829577d490908e3fc6 @jnunemaker committed Dec 28, 2012
Showing with 20 additions and 18 deletions.
  1. +10 −9 README.md
  2. +9 −8 examples/mongo.rb
  3. +1 −1 examples/mongo_atomic.rb
View
@@ -5,21 +5,22 @@ Mongo adapter for adapter gem.
```ruby
require 'adapter/mongo'
-client = Mongo::Connection.new.db('adapter')['testing']
+key = BSON::ObjectId.new
+client = Mongo::MongoClient.new.db('adapter')['testing']
adapter = Adapter[:mongo].new(client)
adapter.clear
-adapter.write('foo', 'bar')
-puts 'Should be bar: ' + adapter.read('foo').inspect
+adapter.write(key, {'some' => 'thing'})
+puts 'Should be {"some" => "thing"}: ' + adapter.read(key).inspect
-adapter.delete('foo')
-puts 'Should be nil: ' + adapter.read('foo').inspect
+adapter.delete(key)
+puts 'Should be nil: ' + adapter.read(key).inspect
-adapter.write('foo', 'bar')
+adapter.write(key, {'some' => 'thing'})
adapter.clear
-puts 'Should be nil: ' + adapter.read('foo').inspect
+puts 'Should be nil: ' + adapter.read(key).inspect
-puts 'Should be bar: ' + adapter.fetch('foo', 'bar')
+puts 'Should be {"some" => "thing"}: ' + adapter.fetch(key, {'some' => 'thing'}).inspect
```
## Flavors
@@ -32,7 +33,7 @@ require 'adapter/mongo_atomic'
key = BSON::ObjectId.new
full_doc = {'a' => 'c', 'b' => 'd'}
partial_doc = {'a' => 'z'}
-client = Mongo::Connection.new.db('adapter')['testing']
+client = Mongo::MongoClient.new.db('adapter')['testing']
adapter = Adapter[:mongo].new(client)
atomic_adapter = Adapter[:mongo_atomic].new(client)
View
@@ -7,18 +7,19 @@
require 'adapter/mongo'
-client = Mongo::Connection.new.db('adapter')['testing']
+key = BSON::ObjectId.new
+client = Mongo::MongoClient.new.db('adapter')['testing']
adapter = Adapter[:mongo].new(client)
adapter.clear
-adapter.write('foo', 'bar')
-puts 'Should be bar: ' + adapter.read('foo').inspect
+adapter.write(key, {'some' => 'thing'})
+puts 'Should be {"some" => "thing"}: ' + adapter.read(key).inspect
-adapter.delete('foo')
-puts 'Should be nil: ' + adapter.read('foo').inspect
+adapter.delete(key)
+puts 'Should be nil: ' + adapter.read(key).inspect
-adapter.write('foo', 'bar')
+adapter.write(key, {'some' => 'thing'})
adapter.clear
-puts 'Should be nil: ' + adapter.read('foo').inspect
+puts 'Should be nil: ' + adapter.read(key).inspect
-puts 'Should be bar: ' + adapter.fetch('foo', 'bar')
+puts 'Should be {"some" => "thing"}: ' + adapter.fetch(key, {'some' => 'thing'}).inspect
View
@@ -10,7 +10,7 @@
key = BSON::ObjectId.new
full_doc = {'a' => 'c', 'b' => 'd'}
partial_doc = {'a' => 'z'}
-client = Mongo::Connection.new.db('adapter')['testing']
+client = Mongo::MongoClient.new.db('adapter')['testing']
adapter = Adapter[:mongo].new(client)
atomic_adapter = Adapter[:mongo_atomic].new(client)

0 comments on commit 2b03470

Please sign in to comment.