Sha256: 937abd93d5f529bd3ff196aad04884eee06c1d0edb77fa539e7b59b53da622a9

Contents?: true

Size: 1.57 KB

Versions: 32

Compression:

Stored size: 1.57 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.
          # @param [ Hash ] options The binding options.
          #
          # @option options [ true, false ] :continue Continue binding the inverse.
          # @option options [ true, false ] :binding Are we in build mode?
          #
          # @since 2.0.0.rc.1
          def bind_one(doc)
            doc.parentize(base)
            binding do
              unless metadata.versioned?
                doc.do_or_do_not(metadata.inverse_setter(target), base)
              end
            end
          end

          # Unbind a single document.
          #
          # @example Unbind the document.
          #   person.addresses.unbind_one(document)
          #
          # @param [ Hash ] options The binding options.
          #
          # @option options [ true, false ] :continue Continue binding the inverse.
          # @option options [ true, false ] :binding Are we in build mode?
          #
          # @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

32 entries across 32 versions & 2 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.6 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.5 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.4 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.3 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.2 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.23 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.1 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.1.0 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.22 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.21 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.20 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.19 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.18 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.17 lib/mongoid/relations/bindings/embedded/many.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.16 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.15 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.14 lib/mongoid/relations/bindings/embedded/many.rb
mongoid-3.0.13 lib/mongoid/relations/bindings/embedded/many.rb