Module: Babik::QuerySet::Countable
- Included in:
- AbstractBase
- Defined in:
- lib/babik/queryset/mixins/countable.rb
Overview
Functionality related to the size of the QuerySet
Instance Method Summary collapse
-
#count ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude.
-
#empty? ⇒ Boolean
Inform if the QuerySet has no elements that match the condition.
-
#exists? ⇒ Boolean
Inform if the QuerySet has at least one element that match the condition.
-
#length ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude.
-
#size ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude.
Instance Method Details
#count ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude.
10 11 12 |
# File 'lib/babik/queryset/mixins/countable.rb', line 10 def count self.all.count end |
#empty? ⇒ Boolean
Inform if the QuerySet has no elements that match the condition.
16 17 18 |
# File 'lib/babik/queryset/mixins/countable.rb', line 16 def empty? self.count.zero? end |
#exists? ⇒ Boolean
Inform if the QuerySet has at least one element that match the condition.
22 23 24 |
# File 'lib/babik/queryset/mixins/countable.rb', line 22 def exists? self.count.positive? end |
#length ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude. Alias of count.
30 31 32 |
# File 'lib/babik/queryset/mixins/countable.rb', line 30 def length self.count end |
#size ⇒ Integer
Return the number of elements that match the condition defined by successive calls of filter and exclude. Alias of count.
38 39 40 |
# File 'lib/babik/queryset/mixins/countable.rb', line 38 def size self.count end |