Module: Mongoid::ByStar

Extended by:
ActiveSupport::Concern
Defined in:
lib/by_star/orm/mongoid/by_star.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#next(options = {}) ⇒ Object



58
59
60
61
# File 'lib/by_star/orm/mongoid/by_star.rb', line 58

def next(options={})
  field = self.class.by_star_start_field
  self.class.by_star_scope(options).gt(field => self.send(field)).asc(field).first
end

#previous(options = {}) ⇒ Object



53
54
55
56
# File 'lib/by_star/orm/mongoid/by_star.rb', line 53

def previous(options={})
  field = self.class.by_star_start_field
  self.class.by_star_scope(options).lt(field => self.send(field)).desc(field).first
end