module QueryHelper::QueryHelperConcern

Public Instance Methods

create_query_helper() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 16
def create_query_helper
  @query_helper = QueryHelper.new(**query_helper_params, api_payload: true)
end
create_query_helper_associations() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 37
def create_query_helper_associations
  QueryHelper::Associations.process_association_params(params[:include])
end
create_query_helper_filter() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 28
def create_query_helper_filter
  filter_values = params[:filter].permit!.to_h
  QueryHelper::SqlFilter.new(filter_values: filter_values)
end
create_query_helper_sort() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 33
def create_query_helper_sort
  QueryHelper::SqlSort.new(sort_string: params[:sort], sort_tiebreak: params[:sort_tiebreak])
end
create_query_helper_with_no_pagination() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 20
def create_query_helper_with_no_pagination
  @query_helper = query_helper_with_no_pagination()
end
query_helper() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 8
def query_helper
  @query_helper
end
query_helper_params() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 41
def query_helper_params
  helpers = query_helper_params_no_pagination
  helpers[:page] = params[:page] if params[:page]
  helpers[:per_page] = params[:per_page] if params[:per_page]
  helpers
end
query_helper_params_no_pagination() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 48
def query_helper_params_no_pagination
  helpers = {}
  helpers[:sql_filter] = create_query_helper_filter() if params[:filter]
  helpers[:sql_sort] = create_query_helper_sort() if params[:sort] || params[:sort_tiebreak]
  helpers[:associations] = create_query_helper_associations() if params[:include]
  helpers[:search_string] = params[:search_for] if params[:search_for]
  helpers
end
query_helper_with_no_pagination() click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 12
def query_helper_with_no_pagination
  QueryHelper.new(**query_helper_params_no_pagination)
end
reload_query_params(query_helper=@query_helper) click to toggle source
# File lib/query_helper/query_helper_concern.rb, line 24
def reload_query_params(query_helper=@query_helper)
  query_helper.update(**query_helper_params)
end