Sha256: 236c132b4c6c65d11bb0af72d4634fc78a5970422651d8fed1fa5ef2eeb66aeb
Contents?: true
Size: 1.06 KB
Versions: 5
Compression:
Stored size: 1.06 KB
Contents
module Mongoid #:nodoc: module Associations #:nodoc: class BelongsTo #:nodoc: include Decorator # Creates the new association by setting the internal # document as the passed in Document. This should be the # parent. # # All method calls on this object will then be delegated # to the internal document itself. def initialize(document, options) @document = document.parent decorate! end # Returns the parent document. The id param is present for # compatibility with rails, however this could be overwritten # in the future. def find(id) @document end class << self # Perform an update of the relationship of the parent and child. This # is initialized by setting a parent object as the association on the # +Document+. Will properly set a has_one or a has_many. def update(parent, child, options) child.parentize(parent, options.inverse_of) child.notify parent end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems