Sha256: 4b9333cf2b298e9986189fec40657a89cb7b3ad99768b0c1a8cf837b58246fd5

Contents?: true

Size: 369 Bytes

Versions: 2

Compression:

Stored size: 369 Bytes

Contents

module ByStar
  module Neighbours
    # Find the previous record to this.
    def previous(field="created_at")
      self.class.past(self.send(field)) { { :order => "#{field} DESC" }}.first
    end
    
    # Find the next record to this.
    def next(field="created_at")
      self.class.future(self.send(field)) { { :order => "#{field} ASC" }}.first
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
by_star-0.7.1 lib/neighbours.rb
by_star-0.7.0 lib/neighbours.rb