Method: Mongo::Grid::File::Info#initialize

Defined in:
lib/mongo/grid/file/info.rb

#initialize(document) ⇒ Info

Create the new file information document.

Examples:

Create the new file information document.

Info.new(:filename => 'test.txt')

Parameters:

  • document (BSON::Document)

    The document to create from.

Since:

  • 2.0.0



139
140
141
142
143
144
145
146
147
148
# File 'lib/mongo/grid/file/info.rb', line 139

def initialize(document)
  @client_md5 = Digest::MD5.new unless document[:disable_md5] == true
  # document contains a mix of user options and keys added
  # internally by the driver, like session.
  # Remove the keys that driver adds but keep user options.
  document = document.reject do |key, value|
    key.to_s == 'session'
  end
  @document = default_document.merge(Options::Mapper.transform(document, MAPPINGS))
end