jsonapi-serializers 2.0.0.pre.beta.1 → 2.0.0.pre.beta.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f99b86af11e529f51cb077d231c973924183808e8d88b0660fa44a2112098a28
4
- data.tar.gz: 80b21e2bd747fa2c838ce4ca73e62f1ecf6121b868fcb8edd045dc4bf31604b0
3
+ metadata.gz: bc0624eff93ecfb4e1b59488acab0da9ef639ee6eb7492ea505dd267b3a36f54
4
+ data.tar.gz: 7d4fd166a854570e74693b641e1a01aba7bd66df3fed17bd7879e8e6a21119f5
5
5
  SHA512:
6
- metadata.gz: 88010cf85c872256685733787d5bb7a74a3dd4ff338797f2f5cd66b3fbc708b5293fbf63c1033d6a4adb56e430d5878be518f3ef98456bf13e3861a08eb6f8ac
7
- data.tar.gz: fd1d79a679235e3115bce25d7b16054cc16097512a52a05df402d0a8ac754c0aad14136054bddbf2c84e99618be9e6058a220e0e64ddbe6e0eb99b6c0c8082b0
6
+ metadata.gz: 932fb952443eb58d8828f739f9b20090acbbb33a0aae4a45feef5e59d116febff63abc8fae9534c895f731978d1a55f17c7e2e7d35c28f1e52c71c8a43d630ad
7
+ data.tar.gz: 67d64725bf7f960f45070dfe4d76cdd81667ed103fbe3e483370ff23b33e86797796e1853b927a6de73c686a67da2fa83f186b35d84babc7036646c20f49717b
@@ -236,17 +236,25 @@ module JSONAPI
236
236
 
237
237
  def self.find_serializer_class_name(object, options)
238
238
  if options[:namespace]
239
- return "#{options[:namespace]}::#{object.class.name}Serializer"
239
+ "#{options[:namespace]}::#{object.class.name}Serializer"
240
+ else
241
+ "#{object.class.name}Serializer"
240
242
  end
243
+ end
244
+
245
+ def self.find_serializer_class(object, options)
241
246
  if object.respond_to?(:jsonapi_serializer_class_name)
242
- return object.jsonapi_serializer_class_name.to_s
247
+ object.jsonapi_serializer_class_name.to_s.constantize
248
+ else
249
+ memoized_serializer_classes[object.class][options[:namespace]] ||=
250
+ find_serializer_class_name(object, options).constantize
243
251
  end
244
- "#{object.class.name}Serializer"
245
252
  end
246
253
 
247
- def self.find_serializer_class(object, options)
248
- class_name = find_serializer_class_name(object, options)
249
- class_name.constantize
254
+ def self.memoized_serializer_classes
255
+ @memoized_serializer_classes ||= {}.tap do |hash|
256
+ hash.default_proc = ->(hash, key) { hash[key] = {} }
257
+ end
250
258
  end
251
259
 
252
260
  def self.find_serializer(object, options)
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Serializer
3
- VERSION = '2.0.0-beta.1'
3
+ VERSION = '2.0.0-beta.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-serializers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.pre.beta.1
4
+ version: 2.0.0.pre.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Fotinakis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-19 00:00:00.000000000 Z
11
+ date: 2019-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: 1.3.1
152
152
  requirements: []
153
- rubygems_version: 3.0.4
153
+ rubygems_version: 3.0.2
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: Pure Ruby readonly serializers for the JSON:API spec.