Sha256: a0487c0befea5446adbf82b87820d495a4c475fcaab468baedb6815031d2eca2
Contents?: true
Size: 1005 Bytes
Versions: 1
Compression:
Stored size: 1005 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Extensions #:nodoc: module Hash #:nodoc: module Assimilation #:nodoc: # Introduces a child object into the +Document+ object graph. This will # set up the relationships between the parent and child and update the # attributes of the parent +Document+. # # Options: # # parent: The +Document+ to assimilate into. # options: The association +Options+ for the child. # # Example: # # <tt>{:first_name => "Hank", :last_name => "Moody"}.assimilate(name, options)</tt> # # Returns: The child +Document+. def assimilate(parent, options, type = nil) klass = type ? type : options.klass child = klass.instantiate(:_parent => parent) child.write_attributes(self.merge(:_type => klass.name)) child.generate_key child.assimilate(parent, options) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-1.0.5 | lib/mongoid/extensions/hash/assimilation.rb |