Class: Monga::Protocol::Insert

Inherits:
Request
  • Object
show all
Defined in:
lib/monga/protocol/insert.rb

Constant Summary collapse

FLAGS =
{ 
  continue_on_error: 0,
}

Constants inherited from Request

Request::OP_CODES

Instance Attribute Summary

Attributes inherited from Request

#connection, #request_id

Instance Method Summary collapse

Methods inherited from Request

#callback_perform, #command, #header, #initialize, #parse_response, #perform

Constructor Details

This class inherits a constructor from Monga::Request

Instance Method Details

#bodyObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/monga/protocol/insert.rb', line 9

def body
  @body ||= begin
    documents = @options[:documents]

    msg = ::BinUtils.append_int32_le!(nil, flags)
    msg << full_name << Monga::NULL_BYTE
    case documents
    when Array
      documents.each do |doc|
        msg << doc.to_bson
      end
    when Hash
      msg << documents.to_bson
    end
    msg
  end
end