lib/jsonapi/processor.rb in jsonapi-resources-0.10.6 vs lib/jsonapi/processor.rb in jsonapi-resources-0.10.7
- old
+ new
@@ -63,17 +63,17 @@
find_options)
resource_set.populate!(serializer, context, find_options)
page_options = result_options
- if (JSONAPI.configuration.top_level_meta_include_record_count || (paginator && paginator.class.requires_record_count))
+ if (top_level_meta_include_record_count || (paginator && paginator.requires_record_count))
page_options[:record_count] = resource_klass.count(verified_filters,
context: context,
include_directives: include_directives)
end
- if (JSONAPI.configuration.top_level_meta_include_page_count && paginator && page_options[:record_count])
+ if (top_level_meta_include_page_count && paginator && page_options[:record_count])
page_options[:page_count] = paginator ? paginator.calculate_page_count(page_options[:record_count]) : 1
end
if JSONAPI.configuration.top_level_links_include_pagination && paginator
page_options[:pagination_params] = paginator.links_page_params(page_options.merge(fetched_resources: resource_set))
@@ -195,27 +195,27 @@
find_options)
resource_set.populate!(serializer, context, find_options)
opts = result_options
- if ((JSONAPI.configuration.top_level_meta_include_record_count) ||
- (paginator && paginator.class.requires_record_count) ||
- (JSONAPI.configuration.top_level_meta_include_page_count))
+ if ((top_level_meta_include_record_count) ||
+ (paginator && paginator.requires_record_count) ||
+ (top_level_meta_include_page_count))
opts[:record_count] = source_resource.class.count_related(
source_resource.identity,
relationship_type,
find_options)
end
- if (JSONAPI.configuration.top_level_meta_include_page_count && opts[:record_count])
+ if (top_level_meta_include_page_count && opts[:record_count])
opts[:page_count] = paginator.calculate_page_count(opts[:record_count])
end
opts[:pagination_params] = if paginator && JSONAPI.configuration.top_level_links_include_pagination
page_options = {}
- page_options[:record_count] = opts[:record_count] if paginator.class.requires_record_count
+ page_options[:record_count] = opts[:record_count] if paginator.requires_record_count
paginator.links_page_params(page_options.merge(fetched_resources: resource_set))
else
{}
end
@@ -378,9 +378,17 @@
include_related = include_directives.include_directives[:include_related] if include_directives
resource_id_tree = find_resource_id_tree_from_resource_relationship(resource, relationship_name, options, include_related)
JSONAPI::ResourceSet.new(resource_id_tree)
+ end
+
+ def top_level_meta_include_record_count
+ JSONAPI.configuration.top_level_meta_include_record_count
+ end
+
+ def top_level_meta_include_page_count
+ JSONAPI.configuration.top_level_meta_include_page_count
end
private
def find_related_resource_id_tree(resource_klass, source_id, relationship_name, find_options, include_related)
options = find_options.except(:include_directives)