def embed_collection(name, model)
      embedding << name unless embedding.include?(name)

      define_method(name) do
        return [] unless @embedding.has_key? name

        @_memo[name] ||= begin
                           model = Ork::Utils.const(self.class, model)
                           @embedding[name].map do |atts|
                             new_embedded model, atts
                           end
                         end
      end

      define_method(:"#{name}_add") do |object|
        assert_embeddable object

        object.__parent = self
        @_memo[name] << object if @_memo[name]
        @embedding[name] = Array(@embedding[name]) << object.attributes
      end

      define_method(:"#{name}_remove") do |object|
        assert_embeddable object

        object.__parent = nil
        @_memo[name].delete(object) if @_memo[name]
        @embedding[name].delete(object.attributes) and object if @embedding[name]
      end
    end
def embed_collection(name, model)
      embedding << name unless embedding.include?(name)

      define_method(name) do
        return [] unless @embedding.has_key? name

        @_memo[name] ||= begin
                           model = Ork::Utils.const(self.class, model)
                           @embedding[name].map do |atts|
                             new_embedded model, atts
                           end
                         end
      end

      define_method(:"#{name}_add") do |object|
        assert_embeddable object

        object.__parent = self
        @_memo[name] << object if @_memo[name]
        @embedding[name] = Array(@embedding[name]) << object.attributes
      end

      define_method(:"#{name}_remove") do |object|
        assert_embeddable object

        object.__parent = nil
        @_memo[name].delete(object) if @_memo[name]
        @embedding[name].delete(object.attributes) and object if @embedding[name]
      end
    end
A macro for find embedded objects of the same type, massive assign and
 syntactic sugar for add an object to the collection.

 Example:

   class Post
     include Ork::Document

     embed_collection :authors, :Author
   end

   # It's the same as:

   class Post
     include Ork::Document

     def authors
       # An array of authors
     end

     def authors_add(author)
       # Add an author to the embed collection
     end
   end