Module: Mongo::Grid::FSBucket::Stream

Extended by:
Stream
Included in:
Stream
Defined in:
lib/mongo/grid/stream.rb,
lib/mongo/grid/stream/read.rb,
lib/mongo/grid/stream/write.rb

Overview

A stream that reads and writes files from/to the FSBucket.

Since:

  • 2.1.0

Defined Under Namespace

Classes: Read, Write

Constant Summary collapse

READ_MODE =

The symbol for opening a read stream.

Since:

  • 2.1.0

:r
WRITE_MODE =

The symbol for opening a write stream.

Since:

  • 2.1.0

:w
MODE_MAP =

Mapping from mode to stream class.

Since:

  • 2.1.0

{
    READ_MODE => Read,
    WRITE_MODE => Write
}.freeze

Instance Method Summary collapse

Instance Method Details

#get(fs, mode, options = {}) ⇒ Stream::Read, Stream::Write

Get a stream for reading/writing files from/to the FSBucket.

Examples:

Get a stream.

FSBucket::Stream.get(fs, FSBucket::READ_MODE, options)

Parameters:

  • fs (FSBucket)

    The GridFS bucket object.

  • mode (FSBucket::READ_MODE, FSBucket::WRITE_MODE)

    The stream mode.

  • options (Hash) (defaults to: {})

    The stream options.

Returns:

Since:

  • 2.1.0



61
62
63
# File 'lib/mongo/grid/stream.rb', line 61

def get(fs, mode, options = {})
  MODE_MAP[mode].new(fs, options)
end