Sha256: 69dd60eeeb4f2f00a62822230bf458cd64d5c8640d2b73c270e66f43f0356d76
Contents?: true
Size: 662 Bytes
Versions: 13
Compression:
Stored size: 662 Bytes
Contents
# encoding: utf-8 require "mongoid/modifiers/command" require "mongoid/modifiers/inc" module Mongoid #:nodoc: module Modifiers #:nodoc: extend ActiveSupport::Concern # Increment the field by the provided value, else if it doesn't exists set # it to that value. # # Options: # # field: The field to increment. # value: The value to increment by. # options: Options to pass through to the driver. def inc(field, value, options = {}) current = send(field) write_attribute(field, (current ? (current + value) : value)) Inc.new(self, options).persist(field, value) current + value end end end
Version data entries
13 entries across 13 versions & 2 rubygems