Sha256: 069f96e36810a67d4a544ef3b3cce131303c1180ee2fbdc14cbcf98b6c1ce5d0

Contents?: true

Size: 342 Bytes

Versions: 4

Compression:

Stored size: 342 Bytes

Contents

class Post < DataMapper::Base
  property :title, :string
  property :created_at, :datetime
  
  def next
    Post.first(:created_at.gte => self.created_at, :id.gt => self.id, :order => "created_at, id")
  end

  def previous
    Post.first(:created_at.lte => self.created_at, :id.lt => self.id, :order => "created_at DESC, id DESC")
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
datamapper-0.2.1 spec/models/post.rb
datamapper-0.2.3 spec/models/post.rb
datamapper-0.2.2 spec/models/post.rb
datamapper-0.2.4 spec/models/post.rb