module Babik::QuerySet::Bounded
Every QuerySet
is bounded by its first and last items
Public Instance Methods
earliest(*order)
click to toggle source
Return the first element given some order @param order [Array, String, Hash] ordering that will be applied to the QuerySet
.
See {Babik::QuerySet::Sortable#order_by}.
@return [ActiveRecord::Base] First element according to the order.
# File lib/babik/queryset/mixins/bounded.rb, line 12 def earliest(*order) self.order_by(*order).first end
first()
click to toggle source
last()
click to toggle source
latest(*order)
click to toggle source
Return the last element given some order @param order [Array, String, Hash] ordering that will be applied to the QuerySet
.
See {Babik::QuerySet::Sortable#order_by}.
@return [ActiveRecord::Base] Last element according to the order.
# File lib/babik/queryset/mixins/bounded.rb, line 32 def latest(*order) self.order_by(*order).last end