Sha256: aa259dcc47b90acd03e9067fcc4a14e061ea895d79e50af48314e154e7e8f3c0

Contents?: true

Size: 881 Bytes

Versions: 12

Compression:

Stored size: 881 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Persistable

    # Defines behaviour for $set operations.
    #
    # @since 4.0.0
    module Settable
      extend ActiveSupport::Concern

      # Perform a $set operation on the provided field/value pairs and set the
      # values in the document in memory.
      #
      # @example Set the values.
      #   document.set(title: "sir", dob: Date.new(1970, 1, 1))
      #
      # @param [ Hash ] setters The field/value pairs to set.
      #
      # @return [ true ] If the operation succeeded.
      #
      # @since 4.0.0
      def set(setters)
        prepare_atomic_operation do |ops|
          process_atomic_operations(setters) do |field, value|
            send("#{field}=", value)
            ops[atomic_attribute_name(field)] = attributes[field]
          end
          { "$set" => ops }
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 4 rubygems

Version Path
mongoid-4.0.1 lib/mongoid/persistable/settable.rb
mongoid-4.0.0 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.rc2 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.rc1 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.beta2 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.beta1 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.alpha2 lib/mongoid/persistable/settable.rb
mongoid-4.0.0.alpha1 lib/mongoid/persistable/settable.rb
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/persistable/settable.rb
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/persistable/settable.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/persistable/settable.rb
mongoid_rails4-4.0.0 lib/mongoid/persistable/settable.rb