Skip to content

Commit

Permalink
Merge 20c93f3 into 85e1466
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjlynch committed Aug 9, 2013
2 parents 85e1466 + 20c93f3 commit 0e1945f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 59 deletions.
63 changes: 4 additions & 59 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,62 +1,7 @@
Mongoid [![Build Status](https://secure.travis-ci.org/mongoid/mongoid.png?branch=master)](http://travis-ci.org/mongoid/mongoid) [![Code Climate](https://codeclimate.com/github/mongoid/mongoid.png)](https://codeclimate.com/github/mongoid/mongoid) [![Coverage Status](https://coveralls.io/repos/mongoid/mongoid/badge.png?branch=master)](https://coveralls.io/r/mongoid/mongoid?branch=master)
========
I have edided this version of mongoid to add the method "as_document" to support has_many relationships

Mongoid is an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.
Without this change, the error "undefined method as_document for array" will be returned when the following is called:

Project Tracking
----------------
@person.as_document

* [Mongoid Google Group](http://groups.google.com/group/mongoid)
* [Mongoid Website and Documentation](http://mongoid.org)
* [Mongoid Code Climate](https://codeclimate.com/github/mongoid/mongoid)

Compatibility
-------------

Mongoid is tested against MRI 1.9.3, 2.0.0, and JRuby (1.9).

Documentation
-------------

Please see the new Mongoid website for up-to-date documentation:
[mongoid.org](http://mongoid.org)

Donating
--------

[Support Mongoid at Pledgie](http://www.pledgie.com/campaigns/7757)

<a href='http://www.pledgie.com/campaigns/7757'>
<img alt='Click here to lend your support to: Mongoid and make a donation at www.pledgie.com !' src='http://www.pledgie.com/campaigns/7757.png?skin_name=chrome' border='0'/>
</a>

[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=durran&url=http://github.com/mongoid&title=mongoid&language=&tags=github&category=software)

License
-------

Copyright (c) 2009-2013 Durran Jordan

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Credits
-------

Durran Jordan: durran at gmail dot com
If @person has_many children
15 changes: 15 additions & 0 deletions lib/mongoid/criteria.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,21 @@ def cached?
def documents
@documents ||= []
end

# These methods are needed for has_many relationships
# They are included for embeds_many relationships but not has_many relationships

def as_document
attributes = []
_unscoped.each do |doc|
attributes.push(doc.as_document)
end
attributes
end

def _unscoped
@_unscoped ||= []
end

# Set the embedded documents on the criteria.
#
Expand Down

0 comments on commit 0e1945f

Please sign in to comment.