lib/mongoid/association/macros.rb in mongoid-8.0.5 vs lib/mongoid/association/macros.rb in mongoid-8.0.6
- old
+ new
@@ -33,14 +33,19 @@
# @return [ Hash<String, String> ] The aliased associations hash.
#
# @api private
class_attribute :aliased_associations
+ # @return [ Set<String> ] The set of associations that are configured
+ # with :store_as parameter.
+ class_attribute :stored_as_associations
+
self.embedded = false
self.embedded_relations = BSON::Document.new
self.relations = BSON::Document.new
self.aliased_associations = {}
+ self.stored_as_associations = Set.new
end
# This is convenience for libraries still on the old API.
#
# @example Get the associations.
@@ -217,9 +222,10 @@
Association::MACRO_MAPPING[macro_name].new(self, name, options, &block).tap do |assoc|
assoc.setup!
self.relations = self.relations.merge(name => assoc)
if assoc.embedded? && assoc.respond_to?(:store_as) && assoc.store_as != name
self.aliased_associations[assoc.store_as] = name
+ self.stored_as_associations << assoc.store_as
end
end
end
end
end