Sha256: c62cab1d8536b2993d55f9a771d83527c187a462861b97e062cb45105c971fcc

Contents?: true

Size: 1.09 KB

Versions: 188

Compression:

Stored size: 1.09 KB

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Atomic #:nodoc:
    module Paths #:nodoc:

      # This class encapsulates behaviour for locating and updating root
      # documents atomically.
      class Root

        attr_reader :document, :path, :position

        # Create the new root path utility.
        #
        # @example Create the root path util.
        #   Root.new(document)
        #
        # @param [ Document ] document The document to generate the paths for.
        #
        # @since 2.1.0
        def initialize(document)
          @document, @path, @position = document, "", ""
        end

        # Get the selector to use for the root document when performing atomic
        # updates. When sharding this will include the shard key.
        #
        # @example Get the selector.
        #   root.selector
        #
        # @return [ Hash ] The selector to identify the document with.
        #
        # @since 2.1.0
        def selector
          { "_id" => document.identifier || document._id }.
            merge!(document.shard_key_selector)
        end
      end
    end
  end
end

Version data entries

188 entries across 96 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
mongoid-2.8.1 lib/mongoid/atomic/paths/root.rb
mongoid-2.8.0 lib/mongoid/atomic/paths/root.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/atomic/paths/root.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/atomic/paths/root.rb