Class: Lcms::Engine::AdminDocumentsQuery

Inherits:
BaseQuery
  • Object
show all
Defined in:
app/queries/lcms/engine/admin_documents_query.rb

Overview

Usage:

@documents = AdminDocumentsQuery.call(query_params, page: params[:page])

Instance Method Summary collapse

Methods inherited from BaseQuery

call, #initialize

Constructor Details

This class inherits a constructor from Lcms::Engine::BaseQuery

Instance Method Details

#callObject

Returns: ActiveRecord relation



10
11
12
13
14
15
16
17
18
19
# File 'app/queries/lcms/engine/admin_documents_query.rb', line 10

def call
  @scope = Document.includes(:materials, :resource).all # initial scope
  apply_filters

  if @pagination.present?
    sorted_scope.paginate(page: @pagination[:page])
  else
    sorted_scope
  end
end