Sha256: dc1ac5fb42006537c82394bc9e1521d8011b7ccc790ca75bbb2ff2538a83d70e
Contents?: true
Size: 1.56 KB
Versions: 65
Compression:
Stored size: 1.56 KB
Contents
# encoding: utf-8 module Mongoid # :nodoc: module Relations #:nodoc: module Bindings #:nodoc: module Referenced #:nodoc: # Binding class for references_many relations. class Many < Binding # Binds a single document with the inverse relation. Used # specifically when appending to the proxy. # # @example Bind one document. # person.posts.bind_one(post) # # @param [ Document ] doc The single document to bind. # # @since 2.0.0.rc.1 def bind_one(doc) unless _binding? _binding do doc.you_must(metadata.foreign_key_setter, base.id) if metadata.type doc.you_must(metadata.type_setter, base.class.model_name) end doc.send(metadata.inverse_setter, base) end end end # Unbind a single document. # # @example Unbind the document. # person.posts.unbind_one(document) # # @param [ Document ] document The document to unbind. # # @since 2.0.0.rc.1 def unbind_one(doc) unless _binding? _binding do doc.you_must(metadata.foreign_key_setter, nil) if metadata.type doc.you_must(metadata.type_setter, nil) end doc.send(metadata.inverse_setter, nil) end end end end end end end end
Version data entries
65 entries across 65 versions & 4 rubygems