Sha256: f259472e7782dadbecc7ce2b0eb10491ae17db323f226f4ab554faf59bcd891e

Contents?: true

Size: 659 Bytes

Versions: 13

Compression:

Stored size: 659 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Modifiers #:nodoc:
    class Inc < Command #:nodoc:

      # Execute the persistence operation. This will increment the provided
      # field by the supplied value. If no field exists, it will be created and
      # set to the value provided.
      #
      # Options:
      #
      # field: The field to increment.
      # value: The number to increment by.
      def persist(field, value)
        @document.collection.update(
          @document._selector,
          { "$inc" => { field => value } },
          :safe => safe_mode?(@options),
          :multi => false
        )
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
mongoid-2.0.0.rc.7 lib/mongoid/modifiers/inc.rb
stonegao-mongoid-2.0.0.rc.6 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.6 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.5 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.4 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.3 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.2 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.rc.1 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.beta.20 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.beta.19 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.beta.18 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.beta.17 lib/mongoid/modifiers/inc.rb
mongoid-2.0.0.beta.16 lib/mongoid/modifiers/inc.rb