primalize-jsonapi 0.1.3 → 0.1.4

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: e462c6e45374dd57c9f5f917f27fd9663aac1d0b3e52bca7cf0f7f7e0f7678d1
4
- data.tar.gz: cde0c817337276215b02fa6a60c5418d1f77b8c063898da37e6420d83eb2891a
3
+ metadata.gz: 3350f0fd1aad3c862179c3a156a3d664bcf178d2e03205a67c77c735f9537fd5
4
+ data.tar.gz: 61448a12418885035336205324c3755a9556d25d60a7f9cfc332b02ab9fcaab2
5
5
  SHA512:
6
- metadata.gz: d4cc1628d08186773cf267b1a56c60e103c12bdd971e290c208eb4bbcfadee7b838ce132a44c9d552f8d16cbf5fae20d5c8f5aabacbd7f5d5061a42b8a4c5a3b
7
- data.tar.gz: 60b384baf07c164ccef70630abcfffb88ff09efcd44befd32bfbe3644793a8abad4982aa4a25617c41f4ca61bd668445b5e885b4b37fa37582721df6ca4e6b4c
6
+ metadata.gz: 1066244c0722528c54ac831365f11f9711a8ad9e45102d11e237c0530848b8fb2fddffc1a5da592bf8a86080ebc4829215c3aec71a93c7d798c0172f0aab836e
7
+ data.tar.gz: 4f9821abd4eb1c960136298faf5a33e88a892a6e54a9b6edfd41e07b827a1ca8413d66736a343b4ae4d9909d7064e35b736afafc3f1bdef6789a2e7707f2b62b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Primalize::JSONAPI
2
2
 
3
- This is a JSON-API adapter for the [`primalize` gem](https://github.com/jgaskins/primalize). It aims to provide some level of compatibility with the JSON-API spec while still allowing for the type checking of Primalize.
3
+ This is a JSON-API adapter for the [`primalize` gem](https://github.com/jgaskins/primalize), which provides type-checked serializers for Ruby web APIs. It aims to provide some level of compatibility with the JSON-API spec while still allowing for the type checking of Primalize.
4
4
 
5
5
  ## Installation
6
6
 
@@ -40,11 +40,16 @@ class OrderSerializer < Primalize::JSONAPI[Order]
40
40
  )
41
41
 
42
42
  # Associations are similar to other serialization gems, but you need to
43
- # specify the serializer. There is no runtime inference. We do it inside
43
+ # specify the serializer. There is no runtime inference yet. We do it inside
44
44
  # a block in case it has not been loaded yet.
45
45
  has_many(:line_items) { LineItemSerializer }
46
46
  has_one(:customer) { CustomerSerializer }
47
47
  end
48
+ ```
49
+
50
+ ## Performance
51
+
52
+ Even with type checking, performance is still [over 12x](https://github.com/Netflix/fast_jsonapi/pull/42#issuecomment-364693269) that of `ActiveModel::Serializers`. Netflix's `fast_jsonapi` is faster, but doesn't provide type the type safety of Primalize.
48
53
 
49
54
  ## Development
50
55
 
@@ -145,13 +145,25 @@ module Primalize
145
145
  end
146
146
 
147
147
  def self.model_primalizer
148
+ original_primalizer = self
149
+
148
150
  @model_primalizer ||= Class.new(Single) do
149
151
  def self.attributes **attrs
150
152
  attribute_primalizer.attributes attrs
151
153
  end
152
154
 
153
- def self.attribute_primalizer
155
+ define_singleton_method :to_s do
156
+ "#{original_primalizer}.model_primalizer"
157
+ end
158
+ define_singleton_method(:name) { to_s }
159
+
160
+ define_singleton_method :attribute_primalizer do
154
161
  @attribute_primalizer ||= Class.new(Single) do
162
+ define_singleton_method :to_s do
163
+ "#{original_primalizer}.model_primalizer.attribute_primalizer"
164
+ end
165
+
166
+ define_singleton_method(:name) { to_s }
155
167
  end
156
168
  end
157
169
 
@@ -1,5 +1,5 @@
1
1
  module Primalize
2
2
  module JSONAPI
3
- VERSION = "0.1.3"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primalize-jsonapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Gaskins
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-02-10 00:00:00.000000000 Z
11
+ date: 2018-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: primalize