Created
November 25, 2009 08:06
-
-
Save lennart/242555 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.with_replies(id, options = {}) | |
| options.merge!(:startkey => [id], :endkey => [id,{}], :raw => true, :include_docs => true) | |
| #by_replies calls the view with map_hierarchy.js as the map function | |
| raw_replies = by_replies(options) | |
| return [] if raw_replies.empty? | |
| class_eval do | |
| raw_replies["rows"].map do |row| | |
| if row["key"].size == 1 | |
| new(row["doc"]) | |
| else | |
| [(row["key"].size-1) / 2,new(row["doc"])] | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment