Sha256: d1fd14d7482f99a75862507b7e360ec24765ca60fa8ea1afdde2269ee3b83c73

Contents?: true

Size: 1.24 KB

Versions: 27

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

module Mongoid
  module Association
    module Embedded
      class EmbedsMany

        # Binding class for all embeds_many associations.
        #
        # @since 7.0
        class Binding
          include Bindable

          # Binds a single document with the inverse association. 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(_association.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(_association.inverse_setter(_target), nil)
            end
          end
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.3.5 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.3.4 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.11 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.6 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.3.3 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.3.2 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.5 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.10 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.9 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.4 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.3.1 lib/mongoid/association/embedded/embeds_many/binding.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.3.0 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.3 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.8 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.2 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.1 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.7 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.2.0 lib/mongoid/association/embedded/embeds_many/binding.rb
mongoid-7.1.6 lib/mongoid/association/embedded/embeds_many/binding.rb