From abf59fd14cb9e7880e1c3ca2e1cac52757540039 Mon Sep 17 00:00:00 2001 From: Claudio Maradonna Date: Fri, 6 Dec 2024 22:41:30 +0100 Subject: [PATCH] add compatibility to Oj gem for faster JSON support --- lib/jsonapi/renderer/cached_resources_processor.rb | 7 +------ spec/caching_spec.rb | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/jsonapi/renderer/cached_resources_processor.rb b/lib/jsonapi/renderer/cached_resources_processor.rb index 3f77228..7e9884b 100644 --- a/lib/jsonapi/renderer/cached_resources_processor.rb +++ b/lib/jsonapi/renderer/cached_resources_processor.rb @@ -5,9 +5,6 @@ class Renderer # @private class CachedResourcesProcessor < ResourcesProcessor class JSONString < String - def to_json(*) - self - end end def initialize(cache) @@ -19,9 +16,7 @@ def process_resources cache_hash = cache_key_map(resources) processed_resources = @cache.fetch_multi(*cache_hash.keys) do |key| res, include, fields = cache_hash[key] - json = res.as_jsonapi(include: include, fields: fields).to_json - - JSONString.new(json) + res.as_jsonapi(include: include, fields: fields) end resources.replace(processed_resources.values) diff --git a/spec/caching_spec.rb b/spec/caching_spec.rb index 35c605c..1b5d6fb 100644 --- a/spec/caching_spec.rb +++ b/spec/caching_spec.rb @@ -96,6 +96,6 @@ def fetch_multi(*keys) } expect(JSON.parse(actual.to_json)).to eq(JSON.parse(expected.to_json)) - expect(actual[:data]).to be_a(JSONAPI::Renderer::CachedResourcesProcessor::JSONString) + # expect(actual[:data]).to be_a(JSONAPI::Renderer::CachedResourcesProcessor::JSONString) end end