module Babik::QuerySet::Countable
Functionality related to the size of the QuerySet
Public Instance Methods
Return the number of elements that match the condition defined by successive calls of filter and exclude. @return [Integer] Number of elements that match the condition defined in this QuerySet
.
# File lib/babik/queryset/mixins/countable.rb, line 10 def count self.all.count end
Inform if the QuerySet
has no elements that match the condition. @return [Boolean] True if no records match the filter, false otherwise.
# File lib/babik/queryset/mixins/countable.rb, line 16 def empty? self.count.zero? end
Inform if the QuerySet
has at least one element that match the condition. @return [Boolean] True if one or more records match the filter, false otherwise.
# File lib/babik/queryset/mixins/countable.rb, line 22 def exists? self.count.positive? end
Return the number of elements that match the condition defined by successive calls of filter and exclude. Alias of count. @see Babik::QuerySet::Countable#count
@return [Integer] Number of elements that match the condition defined in this QuerySet
.
# File lib/babik/queryset/mixins/countable.rb, line 30 def length self.count end
Return the number of elements that match the condition defined by successive calls of filter and exclude. Alias of count. @see Babik::QuerySet::Countable#count
@return [Integer] Number of elements that match the condition defined in this QuerySet
.
# File lib/babik/queryset/mixins/countable.rb, line 38 def size self.count end