Class: Moped::GridFS::Files
- Inherits:
-
Object
- Object
- Moped::GridFS::Files
- Includes:
- Enumerable, Bucketable
- Defined in:
- lib/moped/gridfs/files.rb
Instance Attribute Summary collapse
-
#bucket ⇒ Object
readonly
Returns the value of attribute bucket.
Instance Method Summary collapse
- #[](id) ⇒ Object
- #count ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(bucket) ⇒ Files
constructor
A new instance of Files.
Methods included from Bucketable
#chunks_collection, #files_collection
Constructor Details
#initialize(bucket) ⇒ Files
Returns a new instance of Files.
12 13 14 |
# File 'lib/moped/gridfs/files.rb', line 12 def initialize(bucket) @bucket = bucket end |
Instance Attribute Details
#bucket ⇒ Object (readonly)
Returns the value of attribute bucket.
10 11 12 |
# File 'lib/moped/gridfs/files.rb', line 10 def bucket @bucket end |
Instance Method Details
#[](id) ⇒ Object
16 17 18 |
# File 'lib/moped/gridfs/files.rb', line 16 def [](id) bucket.open(id, 'r') end |
#count ⇒ Object
20 21 22 |
# File 'lib/moped/gridfs/files.rb', line 20 def count files_collection.find.count end |
#each(&block) ⇒ Object
24 25 26 |
# File 'lib/moped/gridfs/files.rb', line 24 def each(&block) files_collection.find.each { |document| yield(self[document['_id']]) } end |