Module: ByStar::Neighbours
- Included in:
- InstanceMethods
- Defined in:
- lib/by_star/neighbours.rb
Instance Method Summary collapse
-
#next(field = nil) ⇒ Object
Find the next record to this.
-
#previous(field = nil) ⇒ Object
Find the previous record to this.
Instance Method Details
#next(field = nil) ⇒ Object
Find the next record to this.
10 11 12 13 |
# File 'lib/by_star/neighbours.rb', line 10 def next(field=nil) field = field || self.class.by_star_field self.class.future(self.send(field.to_s.split(".").last)) { { :order => "#{field} ASC" }}.first end |
#previous(field = nil) ⇒ Object
Find the previous record to this.
4 5 6 7 |
# File 'lib/by_star/neighbours.rb', line 4 def previous(field=nil) field = field || self.class.by_star_field self.class.past(self.send(field.to_s.split(".").last)) { { :order => "#{field} DESC" }}.first end |