Permalink
Browse files

* added Post#next, Post#prev method that return next|prev post instance

  • Loading branch information...
1 parent f024961 commit b39a6c97b7ff1bd0ea8b9345c01556b47b0118a5 @noriaki noriaki committed Feb 7, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/lokka/entry.rb
View
@@ -187,6 +187,20 @@ def link
orig_link
end
end
+
+ def next
+ @next ||= self.class.first(
+ :draft => false,
+ :created_at.gt => self.created_at,
+ :order => [:created_at.asc])
+ end
+
+ def prev
+ @prev ||= self.class.first(
+ :draft => false,
+ :created_at.lt => self.created_at,
+ :order => [:created_at.desc])
+ end
end
def Post(id_or_slug)

0 comments on commit b39a6c9

Please sign in to comment.