Sha256: 8c461cf0bcb3a39ca314b2996faad215cc7d9d8b0faa7fd6b461d1c994435876
Contents?: true
Size: 1 KB
Versions: 3
Compression:
Stored size: 1 KB
Contents
# Adapter for the `ransack` gem. class RESTFramework::Filters::RansackFilter < RESTFramework::Filters::BaseFilter # Filter data according to the request query parameters. def filter_data(data) q = @controller.request.query_parameters[@controller.class.ransack_query_param] if q.present? distinct = @controller.class.ransack_distinct # Determine if `distinct` is determined by query param. if distinct_query_param = @controller.class.ransack_distinct_query_param if distinct_query = @controller.request.query_parameters[distinct_query_param].presence distinct_from_query = ActiveRecord::Type::Boolean.new.cast(distinct_query) unless distinct_from_query.nil? distinct = distinct_from_query end end end return data.ransack(q, @controller.class.ransack_options || {}).result(distinct: distinct) end return data end end # Alias for convenience. RESTFramework::RansackFilter = RESTFramework::Filters::RansackFilter
Version data entries
3 entries across 3 versions & 1 rubygems