lib/jsonapi/response_document.rb in jsonapi-resources-0.7.1.beta1 vs lib/jsonapi/response_document.rb in jsonapi-resources-0.7.1.beta2
- old
+ new
@@ -52,10 +52,14 @@
meta.merge!(result.meta)
if JSONAPI.configuration.top_level_meta_include_record_count && result.respond_to?(:record_count)
meta[JSONAPI.configuration.top_level_meta_record_count_key] = result.record_count
end
+
+ if JSONAPI.configuration.top_level_meta_include_page_count && result.respond_to?(:page_count)
+ meta[JSONAPI.configuration.top_level_meta_page_count_key] = result.page_count
+ end
end
meta.deep_transform_keys { |key| @key_formatter.format(key) }
end
@@ -88,13 +92,20 @@
def query_params(params)
query_params = {}
query_params[:page] = params
request = @options[:request]
- query_params[:fields] = request.params[:fields] if request.params[:fields]
+ if request.params[:fields]
+ query_params[:fields] = request.params[:fields].respond_to?(:to_unsafe_hash) ? request.params[:fields].to_unsafe_hash : request.params[:fields]
+ end
+
query_params[:include] = request.params[:include] if request.params[:include]
query_params[:sort] = request.params[:sort] if request.params[:sort]
- query_params[:filter] = request.params[:filter] if request.params[:filter]
+
+ if request.params[:filter]
+ query_params[:filter] = request.params[:filter].respond_to?(:to_unsafe_hash) ? request.params[:filter].to_unsafe_hash : request.params[:filter]
+ end
+
query_params
end
def results_to_hash
if @operation_results.has_errors?