Class: Terror::Post

Inherits:
Object
  • Object
show all
Includes:
DataMapper::Resource, FeedFetcher
Defined in:
lib/terror/post.rb

Class Method Summary collapse

Methods included from FeedFetcher

included

Class Method Details

.paginate(options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/terror/post.rb', line 14

def self.paginate(options = {})
  per_page     = options[:per_page]
  page         = options[:page].to_i > 0 ? options[:page].to_i : 1
  posts        = self.all(:order => [:date.desc], :limit => per_page, :offset => per_page * (page - 1))            
  add_pagination_info(posts, per_page, page)
end