pool views

This commit is contained in:
albert
2011-02-25 17:41:00 -05:00
parent f48000a8b5
commit 6d0157265c
39 changed files with 1213 additions and 674 deletions

View File

@@ -0,0 +1,33 @@
module PostSets
class Pool < Base
attr_reader :pool
def initialize(pool, options = {})
@pool = pool
@count = pool.post_id_array.size
super(options)
end
def tags
"pool:#{pool.name}"
end
def load_posts
@posts = pool.posts(:limit => limit, :offset => offset)
end
def sorted_posts
sort_posts(@posts)
end
private
def sort_posts(posts)
posts_by_id = posts.inject({}) do |hash, post|
hash[post.id] = post
hash
end
@pool.post_id_array.map {|x| posts_by_id[x]}
end
end
end