minor: fix for default root collection on gridfs
This commit is contained in:
parent
a6310a0a4f
commit
7863b37f07
|
@ -49,11 +49,11 @@ module GridFS
|
|||
#
|
||||
# @core gridfs
|
||||
class GridStore
|
||||
include Enumerable
|
||||
|
||||
DEFAULT_ROOT_COLLECTION = 'fs'
|
||||
DEFAULT_CONTENT_TYPE = 'text/plain'
|
||||
|
||||
include Enumerable
|
||||
DEFAULT_CONTENT_TYPE = 'text/plain'
|
||||
|
||||
attr_accessor :filename
|
||||
|
||||
|
@ -94,7 +94,7 @@ module GridFS
|
|||
# @param [String] root_collection the name of the gridfs root collection.
|
||||
#
|
||||
# @return [Boolean]
|
||||
def self.exist?(db, name, root_collection=DEFAULT_ROOT_COLLECTION)
|
||||
def self.exist?(db, name, root_collection=GridStore.default_root_collection)
|
||||
db.collection("#{root_collection}.files").find({'filename' => name}).next_document != nil
|
||||
end
|
||||
|
||||
|
@ -144,7 +144,7 @@ module GridFS
|
|||
# @param [String] root_collection the name of the root collection.
|
||||
#
|
||||
# @return [Array]
|
||||
def self.list(db, root_collection=DEFAULT_ROOT_COLLECTION)
|
||||
def self.list(db, root_collection=GridStore.default_root_collection)
|
||||
db.collection("#{root_collection}.files").find().map do |f|
|
||||
f['filename']
|
||||
end
|
||||
|
@ -182,13 +182,14 @@ module GridFS
|
|||
end
|
||||
|
||||
# Rename a file in this collection. Note that this method uses
|
||||
# Collection#update, which means that you will not be notified
|
||||
# Collection#update, which means that you will not be notified of the
|
||||
# success of the operation.
|
||||
#
|
||||
# @param [Mongo::DB] a MongoDB database.
|
||||
# @param [String] src the name of the source file.
|
||||
# @param [String] dest the name of the destination file.
|
||||
# @param [String] root_collection the name of the default root collection.
|
||||
def self.mv(db, src, dest, root_collection=DEFAULT_ROOT_COLLECTION)
|
||||
def self.mv(db, src, dest, root_collection=GridStore.default_root_collection)
|
||||
db.collection("#{root_collection}.files").update({ :filename => src }, { '$set' => { :filename => dest } })
|
||||
end
|
||||
|
||||
|
|
|
@ -196,7 +196,6 @@ class DBTest < Test::Unit::TestCase
|
|||
def test_user_management
|
||||
@@db.add_user("bob", "secret")
|
||||
@@db.logout
|
||||
p @@users.find.to_a
|
||||
assert @@db.authenticate("bob", "secret")
|
||||
assert @@db.remove_user("bob")
|
||||
assert !@@db.authenticate("bob", "secret")
|
||||
|
|
Loading…
Reference in New Issue