Sha256: 713668145f94e3860fa6a741ead2b645036004fa7fbd7941aa285080bfb4b407

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

# encoding: utf-8
module Mongoid
  module Relations
    module Bindings
      module Embedded

        # Binding class for embeds_many relations.
        class Many < Binding

          # Binds a single document with the inverse relation. Used
          # specifically when appending to the proxy.
          #
          # @example Bind one document.
          #   person.addresses.bind_one(address)
          #
          # @param [ Document ] doc The single document to bind.
          #
          # @since 2.0.0.rc.1
          def bind_one(doc)
            doc.parentize(base)
            binding do
              doc.do_or_do_not(metadata.inverse_setter(target), base)
            end
          end

          # Unbind a single document.
          #
          # @example Unbind the document.
          #   person.addresses.unbind_one(document)
          #
          # @param [ Document ] doc The single document to unbind.
          #
          # @since 2.0.0.rc.1
          def unbind_one(doc)
            binding do
              doc.do_or_do_not(metadata.inverse_setter(target), nil)
            end
          end
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
mongoid-6.4.8 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.7 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.5 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-5.4.1 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.4 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.2 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.1 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-5.4.0 lib/mongoid/relations/bindings/embedded/many.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.4.0 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.3.0 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.2.1 lib/mongoid/relations/bindings/embedded/many.rb
tdiary-5.0.5 vendor/bundle/gems/mongoid-6.2.0/lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.2.0 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-6.1.1 lib/mongoid/relations/bindings/embedded/many.rb