lib/mongoid/association/embedded/embedded_in/proxy.rb in mongoid-7.3.5 vs lib/mongoid/association/embedded/embedded_in/proxy.rb in mongoid-7.4.0
- old
+ new
@@ -1,7 +1,6 @@
# frozen_string_literal: true
-# encoding: utf-8
module Mongoid
module Association
module Embedded
class EmbeddedIn
@@ -32,12 +31,10 @@
# person.name.substitute(new_name)
#
# @param [ Document ] replacement A document to replace the target.
#
# @return [ Document, nil ] The association or nil.
- #
- # @since 2.0.0.rc.1
def substitute(replacement)
unbind_one
unless replacement
_base.delete if persistable?
return nil
@@ -54,24 +51,20 @@
#
# @example Get the binding.
# binding([ address ])
#
# @return [ Binding ] A binding object.
- #
- # @since 2.0.0.rc.1
def binding
Binding.new(_base, _target, _association)
end
# Characterize the document.
#
# @example Set the base association.
# object.characterize_one(document)
#
# @param [ Document ] document The document to set the association metadata on.
- #
- # @since 2.1.0
def characterize_one(document)
unless _base._association
_base._association = _association.inverse_association(document)
end
end
@@ -80,12 +73,10 @@
#
# @example Can we persist the association?
# relation.persistable?
#
# @return [ true, false ] If the association is persistable.
- #
- # @since 2.1.0
def persistable?
_target.persisted? && !_binding? && !_building?
end
class << self
@@ -95,12 +86,10 @@
#
# @example Is this association embedded?
# Association::Embedded::EmbeddedIn.embedded?
#
# @return [ true ] true.
- #
- # @since 2.0.0.rc.1
def embedded?
true
end
# Get the path calculator for the supplied document.
@@ -109,11 +98,9 @@
# Proxy.path(document)
#
# @param [ Document ] document The document to calculate on.
#
# @return [ Root ] The root atomic path calculator.
- #
- # @since 2.1.0
def path(document)
Mongoid::Atomic::Paths::Root.new(document)
end
end
end