Sha256: c5c8ca7d5ce0974d9eff03a373cb59aeed950d0a912edb13d61731385aae8133
Contents?: true
Size: 1.51 KB
Versions: 60
Compression:
Stored size: 1.51 KB
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Persistence module ClassMethods def connection(mongo_connection=nil) assert_supported if mongo_connection.nil? @connection ||= MongoMapper.connection else @connection = mongo_connection end @connection end def set_database_name(name) assert_supported @database_name = name end def database_name assert_supported @database_name end def database assert_supported if database_name.nil? MongoMapper.database else connection.db(database_name) end end def set_collection_name(name) assert_supported @collection_name = name end def collection_name assert_supported @collection_name ||= self.to_s.tableize.gsub(/\//, '.') end def collection assert_supported database.collection(collection_name) end private def assert_supported if embeddable? raise NotSupported.new('This is not supported for embeddable documents at this time.') end end end module InstanceMethods def collection _root_document.class.collection end def database _root_document.class.database end end end end end
Version data entries
60 entries across 60 versions & 7 rubygems