Class: Quo::EagerQuery
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Query
#current_page, #options, #page_size
Instance Method Summary collapse
- #collection ⇒ Object
-
#count ⇒ Object
Optionally return the ‘total_count` option if it has been set.
- #eager? ⇒ Boolean
-
#paged? ⇒ Boolean
Is this query object paged? (when no total count).
- #query ⇒ Object
- #relation? ⇒ Boolean
Methods inherited from Query
call, call!, #compose, #copy, #exists?, #first, #first!, #group, #includes, #initialize, #last, #limit, #none?, #order, #page_count, #preload, #results, #select, #to_a, #to_eager, #to_sql, #transform, #transform?, #unwrap, #unwrap_unpaginated
Methods included from Utilities::Compose
Methods included from Utilities::Sanitize
#sanitize_sql_for_conditions, #sanitize_sql_parameter, #sanitize_sql_string
Methods included from Utilities::Wrap
Methods included from Utilities::Callstack
Constructor Details
This class inherits a constructor from Quo::Query
Instance Method Details
#collection ⇒ Object
17 18 19 |
# File 'lib/quo/eager_query.rb', line 17 def collection raise NotImplementedError, "EagerQuery objects must define a 'collection' method" end |
#count ⇒ Object
Optionally return the ‘total_count` option if it has been set. This is useful when the total count is known and not equal to size of wrapped collection.
8 9 10 |
# File 'lib/quo/eager_query.rb', line 8 def count [:total_count] || super end |
#eager? ⇒ Boolean
30 31 32 |
# File 'lib/quo/eager_query.rb', line 30 def eager? true end |
#paged? ⇒ Boolean
Is this query object paged? (when no total count)
13 14 15 |
# File 'lib/quo/eager_query.rb', line 13 def paged? [:total_count].nil? && current_page.present? end |
#query ⇒ Object
21 22 23 24 |
# File 'lib/quo/eager_query.rb', line 21 def query preload_includes(collection) if [:includes] collection end |
#relation? ⇒ Boolean
26 27 28 |
# File 'lib/quo/eager_query.rb', line 26 def relation? false end |