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



85
86
87
88
# File 'lib/by_star/orm/mongoid/by_star.rb', line 85

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

#previous(options = {}) ⇒ Object



80
81
82
83
# File 'lib/by_star/orm/mongoid/by_star.rb', line 80

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