Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 28th, 2012  |  syntax: None  |  size: 0.42 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. module MongoAccessor
  2.  
  3.   def self.included(base)
  4.     base.extend(ClassMethods)
  5.   end
  6.  
  7.   module ClassMethods
  8.     def mongo_connection
  9.       MongoDB.connection
  10.     end
  11.  
  12.     def mongo_collection(collection_name)
  13.       MongoDB.collection(collection_name)
  14.     end
  15.   end
  16.  
  17.   def mongo_connection
  18.     self.class.mongo_connection
  19.   end
  20.  
  21.   def mongo_collection(collection_name)
  22.     self.class.mongo_collection(collection_name)
  23.   end
  24. end