Class: Quo::EagerQuery

Inherits:
Query
  • Object
show all
Defined in:
lib/quo/eager_query.rb

Direct Known Subclasses

LoadedQuery

Instance Attribute Summary

Attributes inherited from Query

#current_page, #options, #page_size

Instance Method Summary collapse

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

#composable_with?, #compose

Methods included from Utilities::Sanitize

#sanitize_sql_for_conditions, #sanitize_sql_parameter, #sanitize_sql_string

Methods included from Utilities::Wrap

#wrap

Methods included from Utilities::Callstack

#debug_callstack

Constructor Details

This class inherits a constructor from Quo::Query

Instance Method Details

#collectionObject

Raises:

  • (NotImplementedError)


17
18
19
# File 'lib/quo/eager_query.rb', line 17

def collection
  raise NotImplementedError, "EagerQuery objects must define a 'collection' method"
end

#countObject

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
  options[:total_count] || super
end

#eager?Boolean

Returns:

  • (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)

Returns:

  • (Boolean)


13
14
15
# File 'lib/quo/eager_query.rb', line 13

def paged?
  options[:total_count].nil? && current_page.present?
end

#queryObject



21
22
23
24
# File 'lib/quo/eager_query.rb', line 21

def query
  preload_includes(collection) if options[:includes]
  collection
end

#relation?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/quo/eager_query.rb', line 26

def relation?
  false
end