Superclass for all objects that bind relations together.
Create the new binding.
@example Initialize a binding.
Binding.new(base, target, metadata)
@param [ Document ] base The base of the binding. @param [ Document, Array<Document> ] target The target of the binding. @param [ Metadata ] metadata The relation's metadata.
@since 2.0.0.rc.1
# File lib/mongoid/relations/binding.rb, line 20 def initialize(base, target, metadata) @base, @target, @metadata = base, target, metadata end
Execute the provided block inside a binding.
@example Execute the binding block.
binding.binding do base.foreign_key = 1 end
@return [ Object ] The result of the yield.
@since 3.0.0
# File lib/mongoid/relations/binding.rb, line 34 def binding unless _binding? _binding do yield(self) if block_given? end end end