Method: Moped::Protocol::Update#initialize

Defined in:
lib/moped/protocol/update.rb

#initialize(database, collection, selector, update, options = {}) ⇒ Update

Create a new update command. The database and collection arguments are joined together to set the full_collection_name.

Examples:

Update.new "moped", "users", { name: "John" }, { name: "Bob" },
  flags: [:upsert],
  request_id: 123

Parameters:

  • database (String, Symbol)

    the database to insert into

  • collection (String, Symbol)

    the collection to insert into

  • selector (Hash)

    the selector

  • update (Hash)

    the update to perform

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

    additional options

Options Hash (options):

  • :request_id (Number)

    the command’s request id

  • :flags (Array)

    the flags for insertion. Supported flags: :upsert, :multi.



89
90
91
92
93
94
95
96
97
98
# File 'lib/moped/protocol/update.rb', line 89

def initialize(database, collection, selector, update, options = {})
  @database = database
  @collection = collection

  @full_collection_name = "#{database}.#{collection}"
  @selector             = selector
  @update               = update
  @request_id           = options[:request_id]
  @flags                = options[:flags]
end