Method: MongoModel::Scope::FinderMethods#last

Defined in:
lib/mongomodel/support/scope/finder_methods.rb

#last(count = nil) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/mongomodel/support/scope/finder_methods.rb', line 33

def last(count=nil)
  if loaded?
    count ? to_a.last(count) : to_a.last
  else
    count ? reverse_order.limit(count).to_a : reverse_order.limit(1).to_a[0]
  end
end