lib/mongoid/association/embedded/embeds_one.rb in mongoid-7.0.13 vs lib/mongoid/association/embedded/embeds_one.rb in mongoid-7.1.0.rc0
- old
+ new
@@ -1,5 +1,8 @@
+# frozen_string_literal: true
+# encoding: utf-8
+
require 'mongoid/association/embedded/embeds_one/binding'
require 'mongoid/association/embedded/embeds_one/buildable'
require 'mongoid/association/embedded/embeds_one/proxy'
module Mongoid
@@ -56,11 +59,11 @@
@store_as ||= (@options[:store_as].try(:to_s) || name.to_s)
end
# The key that is used to get the attributes for the associated object.
#
- # @return [ String ] The name of the field used to store the relation.
+ # @return [ String ] The name of the field used to store the association.
#
# @since 7.0
def key
store_as.to_s
end
@@ -70,11 +73,11 @@
# @return [ true ] Always true.
#
# @since 7.0
def embedded?; true; end
- # Get the default validation setting for the relation. Determines if
+ # Get the default validation setting for the association. Determines if
# by default a validates associated will occur.
#
# @example Get the validation default.
# Proxy.validation_default
#
@@ -90,14 +93,14 @@
# @since 7.0
def stores_foreign_key?; false; end
# The primary key
#
- # @return [ nil ] Not relevant for this relation
+ # @return [ nil ] Not relevant for this association
def primary_key; end
- # Get the relation proxy class for this association type.
+ # Get the association proxy class for this association type.
#
# @return [ Association::Embedded::EmbedsMany::Proxy ] The proxy class.
#
# @since 7.0
def relation
@@ -157,11 +160,10 @@
end
def determine_inverses(other)
matches = relation_class.relations.values.select do |rel|
relation_complements.include?(rel.class) &&
- # https://jira.mongodb.org/browse/MONGOID-4882
- rel.relation_class_name.sub(/\A::/, '') == inverse_class_name
+ rel.relation_class_name == inverse_class_name
end
if matches.size > 1
raise Errors::AmbiguousRelationship.new(relation_class, @owner_class, name, matches)
end