module Rethinker::Selection::First
Public Instance Methods
first()
click to toggle source
# File lib/rethinker/selection/first.rb, line 2 def first self.context[:order] = :normal get_one end
last()
click to toggle source
# File lib/rethinker/selection/first.rb, line 7 def last self.context[:order] = :reverse get_one end
Private Instance Methods
get_one()
click to toggle source
# File lib/rethinker/selection/first.rb, line 14 def get_one klass.ensure_table! # needed as soon as we get a Query_Result order_by(:id) unless ordered? attrs = chain(Rethinker::Criterion.new(:limit, 1)).run.first klass.new_from_db(attrs) end