Sha256: a41991a39be040f3c2c78846f8c1391156aa5350a3ad5b35392d211b4a2c87c1
Contents?: true
Size: 582 Bytes
Versions: 1
Compression:
Stored size: 582 Bytes
Contents
require 'adapter' require 'mongo' module Adapter module Mongo def read(key) if doc = client.find_one('_id' => key_for(key)) decode(doc) end end def write(key, value) client.save({'_id' => key_for(key)}.merge(encode(value)), {:safe => options[:safe]}) end def delete(key) read(key).tap { client.remove({'_id' => key_for(key)}, {:safe => options[:safe]}) } end def clear client.remove end def decode(value) value.delete('_id') value end end end Adapter.define(:mongo, Adapter::Mongo)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
adapter-mongo-0.6.0 | lib/adapter/mongo.rb |