Sha256: 28014f11447b7d4e45e551869b0b2047c17a0d5fd16adb684e0e8d3b0a2a80c6

Contents?: true

Size: 1.25 KB

Versions: 15

Compression:

Stored size: 1.25 KB

Contents

# encoding: utf-8
require "mongoid/atomic/paths/embedded/one"
require "mongoid/atomic/paths/embedded/many"

module Mongoid
  module Atomic
    module Paths

      # Common functionality between the two different embedded paths.
      module Embedded

        attr_reader :delete_modifier, :document, :insert_modifier, :parent

        # Get the path to the document in the hierarchy.
        #
        # @example Get the path.
        #   many.path
        #
        # @return [ String ] The path to the document.
        #
        # @since 2.1.0
        def path
          position.sub(/\.\d+$/, "")
        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.
        #   many.selector
        #
        # @return [ Hash ] The selector to identify the document with.
        #
        # @since 2.1.0
        def selector
          parent.atomic_selector
          # @todo: Durran: Bring this back once MongoDB, if ever, goes to fix
          # this issue: https://jira.mongodb.org/browse/SERVER-831
          # merge!({ "#{path}._id" => document._id }).merge!(document.shard_key_selector)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
mongoid-3.0.23 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.22 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.21 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.20 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.19 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.18 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.17 lib/mongoid/atomic/paths/embedded.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.16 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.15 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.14 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.13 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.12 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.11 lib/mongoid/atomic/paths/embedded.rb
mongoid-3.0.10 lib/mongoid/atomic/paths/embedded.rb