jpie 3.7.0 → 3.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +58 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +3 -1
- data/PERFORMANCE_BASELINE.md +458 -99
- data/README.md +3 -3
- data/Rakefile +5 -0
- data/lib/json_api/active_storage/serialization.rb +23 -6
- data/lib/json_api/controllers/concerns/relationships/serialization.rb +18 -3
- data/lib/json_api/controllers/concerns/resource_actions/include_preloading.rb +58 -12
- data/lib/json_api/controllers/concerns/resource_actions/serialization.rb +55 -13
- data/lib/json_api/railtie.rb +6 -1
- data/lib/json_api/resources/resource_loader.rb +35 -2
- data/lib/json_api/routing.rb +10 -0
- data/lib/json_api/serialization/concerns/include_filtering.rb +7 -41
- data/lib/json_api/serialization/concerns/includes_serialization.rb +7 -15
- data/lib/json_api/serialization/concerns/meta_serialization.rb +8 -5
- data/lib/json_api/serialization/include_filter_cache.rb +113 -0
- data/lib/json_api/serialization/serializer.rb +15 -3
- data/lib/json_api/support/type_conversion.rb +24 -6
- data/lib/json_api/version.rb +1 -1
- metadata +2 -1
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "concurrent/map"
|
|
4
|
+
|
|
3
5
|
module JSONAPI
|
|
4
6
|
module TypeConversion
|
|
7
|
+
# Type names derive only from a class name plus a resolved format, so the
|
|
8
|
+
# serializer re-computes identical strings once per record and per
|
|
9
|
+
# relationship identifier. Cache frozen results keyed by name and format.
|
|
10
|
+
# The railtie clears the cache on code reload.
|
|
11
|
+
@type_name_cache = Concurrent::Map.new
|
|
12
|
+
|
|
13
|
+
def self.reset_cache!
|
|
14
|
+
@type_name_cache.clear
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.type_name_cache
|
|
18
|
+
@type_name_cache
|
|
19
|
+
end
|
|
20
|
+
|
|
5
21
|
module_function
|
|
6
22
|
|
|
7
23
|
def type_to_class_name(type, namespace: nil)
|
|
@@ -19,18 +35,20 @@ module JSONAPI
|
|
|
19
35
|
|
|
20
36
|
def model_type_name(model_class, format: nil)
|
|
21
37
|
format ||= JSONAPI.configuration.namespace_type_format
|
|
38
|
+
name = model_class.name
|
|
39
|
+
return format_type_name(name.underscore.pluralize, format) if name.nil?
|
|
22
40
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
format_type_name(full_name, format)
|
|
41
|
+
cache = TypeConversion.type_name_cache
|
|
42
|
+
cache["m|#{name}|#{format}"] ||= format_type_name(name.underscore.pluralize, format).freeze
|
|
26
43
|
end
|
|
27
44
|
|
|
28
45
|
def resource_type_name(definition_class, format: nil)
|
|
29
46
|
format ||= resolve_type_format(definition_class)
|
|
47
|
+
name = definition_class.name
|
|
48
|
+
return format_type_name(name.sub(/Resource$/, "").underscore.pluralize, format) if name.nil?
|
|
30
49
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
format_type_name(full_name, format)
|
|
50
|
+
cache = TypeConversion.type_name_cache
|
|
51
|
+
cache["r|#{name}|#{format}"] ||= format_type_name(name.sub(/Resource$/, "").underscore.pluralize, format).freeze
|
|
34
52
|
end
|
|
35
53
|
|
|
36
54
|
def format_type_name(full_name, format)
|
data/lib/json_api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jpie
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.8.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Emil Kampp
|
|
@@ -166,6 +166,7 @@ files:
|
|
|
166
166
|
- lib/json_api/serialization/concerns/relationships_deserialization.rb
|
|
167
167
|
- lib/json_api/serialization/concerns/relationships_serialization.rb
|
|
168
168
|
- lib/json_api/serialization/deserializer.rb
|
|
169
|
+
- lib/json_api/serialization/include_filter_cache.rb
|
|
169
170
|
- lib/json_api/serialization/include_path_helpers.rb
|
|
170
171
|
- lib/json_api/serialization/serializer.rb
|
|
171
172
|
- lib/json_api/support/active_storage_support.rb
|