Class: AdminSuite::Query

Inherits:
Object
  • Object
show all
Defined in:
lib/admin_suite/query.rb

Overview

The one place an index-style query is built.

Both the web index action and the MCP list_records tool go through this object, so the two surfaces cannot disagree about what a filter, a sort, or a page size means.

Constant Summary collapse

MAX_PAGE_SIZE =
100

Instance Method Summary collapse

Constructor Details

#initialize(resource_config:, params: {}, max_page_size: MAX_PAGE_SIZE) ⇒ Query

Returns a new instance of Query.



12
13
14
15
16
# File 'lib/admin_suite/query.rb', line 12

def initialize(resource_config:, params: {}, max_page_size: MAX_PAGE_SIZE)
  @resource_config = resource_config
  @params = params || {}
  @max_page_size = max_page_size
end

Instance Method Details

#per_page ⇒ Object



22
23
24
# File 'lib/admin_suite/query.rb', line 22

def per_page
  @per_page ||= clamp(@params[:per_page] || @params["per_page"])
end

#scope ⇒ Object



18
19
20
# File 'lib/admin_suite/query.rb', line 18

def scope
  @scope ||= apply_includes(filtered)
end