Class: Moped::GridFS::Buckets

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/moped/gridfs/buckets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session) ⇒ Buckets

Returns a new instance of Buckets.



10
11
12
# File 'lib/moped/gridfs/buckets.rb', line 10

def initialize(session)
  @session = session
end

Instance Attribute Details

#sessionObject (readonly)

Returns the value of attribute session.



8
9
10
# File 'lib/moped/gridfs/buckets.rb', line 8

def session
  @session
end

Instance Method Details

#[](name) ⇒ Object



22
23
24
# File 'lib/moped/gridfs/buckets.rb', line 22

def [](name)
  Bucket.new(session, name)
end

#countObject



18
19
20
# File 'lib/moped/gridfs/buckets.rb', line 18

def count
  collections.size
end

#each(&block) ⇒ Object



26
27
28
# File 'lib/moped/gridfs/buckets.rb', line 26

def each(&block)
  names.each { |name| yield(self[name]) }
end

#namesObject



14
15
16
# File 'lib/moped/gridfs/buckets.rb', line 14

def names
  collections.map { |collection| collection.name.gsub('.files', '') }
end