Module: MongoMapper::Plugins::Embeddable::ClassMethods
- Defined in:
- lib/mm-embeddable.rb
Instance Method Summary collapse
-
#embeds(*ckeys) ⇒ Object
Tells MongoMapper that this document can be embedded.
Instance Method Details
#embeds(*ckeys) ⇒ Object
Tells MongoMapper that this document can be embedded. Pass in an array of the keys that should be persisted to the embedded document (_id
is automatically persisted as a reference to the full document).
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mm-embeddable.rb', line 54 def (*ckeys) @embeddable_keys ||= [] @embeddable_keys.push(*ckeys) self.const_set(:Embeddable, Class.new(::MongoMapper::Plugins::Embeddable::EmbeddableDocument)) self.const_get(:Embeddable).full_class = self self.const_get(:Embeddable).key :_id, ObjectId ckeys.each do |k| self.const_get(:Embeddable).key k self.const_get(:Embeddable).keys[k.to_s] = self.keys[k.to_s].dup end include MongoMapper::Plugins::Embeddable::EmbeddableMethods end |