lib/mongoid/fields/foreign_key.rb in mongoid-7.3.5 vs lib/mongoid/fields/foreign_key.rb in mongoid-7.4.0

- old
+ new

@@ -1,7 +1,6 @@ # frozen_string_literal: true -# encoding: utf-8 module Mongoid module Fields class ForeignKey < Standard @@ -16,12 +15,10 @@ # @param [ String ] name The name of the field. # @param [ String ] key The atomic location of the field. # @param [ Hash ] mods The current modifications. # @param [ Array ] new_elements The new elements to add. # @param [ Array ] old_elements The old elements getting removed. - # - # @since 2.4.0 def add_atomic_changes(document, name, key, mods, new_elements, old_elements) old = (old_elements || []) new = (new_elements || []) if new.length > old.length if new.first(old.length) == old @@ -45,12 +42,10 @@ # # @example Is the field a foreign key? # field.foreign_key? # # @return [ true, false ] If the field is a foreign key. - # - # @since 2.4.0 def foreign_key? true end # Evolve the object into an id compatible object. @@ -59,12 +54,10 @@ # field.evolve(object) # # @param [ Object ] object The object to evolve. # # @return [ Object ] The evolved object. - # - # @since 3.0.0 def evolve(object) if object_id_field? || object.is_a?(Document) if association.polymorphic? association.convert_to_foreign_key(object) else @@ -79,12 +72,10 @@ # # @example Is the field lazy? # field.lazy? # # @return [ true, false ] If the field is lazy. - # - # @since 3.1.0 def lazy? type.resizable? end # Mongoize the object into the Mongo friendly value. @@ -93,12 +84,10 @@ # field.mongoize(object) # # @param [ Object ] object The object to Mongoize. # # @return [ Object ] The mongoized object. - # - # @since 3.0.0 def mongoize(object) if type.resizable? || object_id_field? type.__mongoize_fk__(association, object) else related_id_field.mongoize(object) @@ -109,12 +98,10 @@ # # @example Is the field a BSON::ObjectId? # field.object_id_field? # # @return [ true, false ] If the field is a BSON::ObjectId. - # - # @since 2.2.0 def object_id_field? @object_id_field ||= association.polymorphic? ? true : association.klass.using_object_ids? end @@ -122,12 +109,10 @@ # # @example Is the field resizable? # field.resizable? # # @return [ true, false ] If the field is resizable. - # - # @since 3.0.2 def resizable? type.resizable? end private @@ -139,12 +124,10 @@ # field.evaluate_default_proc(band) # # @param [ Document ] doc The document. # # @return [ Object ] The called proc. - # - # @since 3.0.0 def evaluate_default_proc(doc) serialize_default(default_val[]) end # Get the id field of the association. @@ -153,12 +136,10 @@ # # @example Get the related id field. # field.related_id_field # # @return [ Fields::Standard ] The field. - # - # @since 3.0.0 def related_id_field @related_id_field ||= association.klass.fields["_id"] end # This is used when default values need to be serialized. Most of the @@ -170,11 +151,9 @@ # field.serialize_default(obj) # # @param [ Object ] object The default. # # @return [ Object ] The serialized default. - # - # @since 3.0.0 def serialize_default(object); object; end end end end