Sha256: acecf7e701954f91f90a75f3cb553533c43a4705b9b228661c906eeb03fbb1f8

Contents?: true

Size: 467 Bytes

Versions: 48

Compression:

Stored size: 467 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Extensions #:nodoc:
    module Array #:nodoc:
      module Accessors #:nodoc:
        # If the attributes already exists in the array then they will be
        # updated, otherwise they will be appended.
        def update(attributes)
          delete_if { |e| attributes["_id"] && (e["_id"] == attributes["_id"]) }
          self.<< attributes
        end

        alias :merge! :update
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 7 rubygems

Version Path
mongoid-1.9.5 lib/mongoid/extensions/array/accessors.rb
mongoid-with-auth-1.9.4 lib/mongoid/extensions/array/accessors.rb
mongoid-rails2-1.9.4 lib/mongoid/extensions/array/accessors.rb
mongoid-rails2-1.9.3 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.20 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.19 lib/mongoid/extensions/array/accessors.rb
mongoid-1.9.2 lib/mongoid/extensions/array/accessors.rb
sskirby-mongoid-1.9.1 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.18 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.17 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.16 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.15 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.14 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.13 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.11 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.10 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.7 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.8 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.9 lib/mongoid/extensions/array/accessors.rb
mongoid-2.0.0.beta.12 lib/mongoid/extensions/array/accessors.rb