major refactoring of post sets and pagination, incomplete

This commit is contained in:
albert
2011-06-03 19:47:16 -04:00
parent ce0695c606
commit ca3e9bb6db
21 changed files with 475 additions and 204 deletions

View File

@@ -0,0 +1,29 @@
module PostSets
module Sequential
attr_reader :before_id, :after_id
def initialize(params)
super
@before_id = params[:before_id]
@after_id = params[:after_id]
end
def slice(relation)
if before_id
relation.where("id < ?", before_id).all
elsif after_id
relation.where("id > ?", after_id).order("id asc").all.reverse
else
relation.all
end
end
def pagination_options
{:before_id => before_id, :after_id => after_id}
end
def is_first_page?
before_id.nil?
end
end
end