lib/mongoid/relations/referenced/many_to_many.rb in mongoid-4.0.0.alpha2 vs lib/mongoid/relations/referenced/many_to_many.rb in mongoid-4.0.0.beta1
- old
+ new
@@ -27,11 +27,11 @@
def <<(*args)
docs = args.flatten
return concat(docs) if docs.size > 1
if doc = docs.first
append(doc)
- base.add_to_set(foreign_key => doc.send(metadata.primary_key))
+ base.add_to_set(foreign_key => doc.send(__metadata.primary_key))
if child_persistable?(doc)
doc.save
end
end
unsynced(base, foreign_key) and self
@@ -112,11 +112,11 @@
#
# @since 2.1.0
def delete(document)
doc = super
if doc && persistable?
- base.pull(foreign_key => doc.send(metadata.primary_key))
+ base.pull(foreign_key => doc.send(__metadata.primary_key))
target._unloaded = criteria
unsynced(base, foreign_key)
end
doc
end
@@ -131,20 +131,20 @@
# @since 2.0.0.rc.1
def nullify
target.each do |doc|
execute_callback :before_remove, doc
end
- unless metadata.forced_nil_inverse?
+ unless __metadata.forced_nil_inverse?
criteria.pull(inverse_foreign_key => base.id)
end
if persistable?
base.set(foreign_key => base.send(foreign_key).clear)
end
after_remove_error = nil
many_to_many = target.clear do |doc|
unbind_one(doc)
- unless metadata.forced_nil_inverse?
+ unless __metadata.forced_nil_inverse?
doc.changed_attributes.delete(inverse_foreign_key)
end
begin
execute_callback :after_remove, doc
rescue => e
@@ -219,11 +219,11 @@
#
# @return [ Binding ] The binding.
#
# @since 2.0.0.rc.1
def binding
- Bindings::Referenced::ManyToMany.new(base, target, metadata)
+ Bindings::Referenced::ManyToMany.new(base, target, __metadata)
end
# Determine if the child document should be persisted.
#
# @api private
@@ -236,21 +236,21 @@
# @return [ true, false ] If the document can be persisted.
#
# @since 3.0.20
def child_persistable?(doc)
(persistable? || _creating?) &&
- !(doc.persisted? && metadata.forced_nil_inverse?)
+ !(doc.persisted? && __metadata.forced_nil_inverse?)
end
# Returns the criteria object for the target class with its documents set
# to target.
#
# @example Get a criteria for the relation.
# relation.criteria
#
# @return [ Criteria ] A new criteria.
def criteria
- ManyToMany.criteria(metadata, base.send(foreign_key))
+ ManyToMany.criteria(__metadata, base.send(foreign_key))
end
# Flag the base as unsynced with respect to the foreign key.
#
# @api private