jsonapi-realizer 4.1.0 → 4.2.1

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: 8cb7f214558b3e9926ec20b9156c10d8e4b00bf29c1b8ef2bbade489a066ece2
4
- data.tar.gz: 29abee993505d8728b4092542207541864baec6dfee5e8d5739996b6d58367d8
3
+ metadata.gz: b4cc7c0ca36909f2b78e77b8b13d77edfdee53a242cf6556d4c9c6e2fb9be737
4
+ data.tar.gz: 73139ddf9d227b9ba71a7e974ccbd0709ed1a7e23da2bd2be8d86c22021c3a35
5
5
  SHA512:
6
- metadata.gz: 8ff7e820e1a2b5222afd5076e4822d31f706302501a1a020c9dd4ae5cb8c327d2cb741b3f687d2e376b876166d1aadd85bfab770542604f76e3ea4ab9d32f26f
7
- data.tar.gz: cf2485faba6a11e199580c619aed6eb888be5a72cb2582ace2c3c29efda84fd6859c4ebc1cde89af841395e59594fa524e94ddf4c874154fd5da0d6a3cbbcbc9
6
+ metadata.gz: c214e9a2462303cedabd80fdba3411f581d03e3ca413abc065fee77bac007b01f61d0e23599cf51be59951483d90257d4dceb0e3ed8cd192b5f4393cddc27230
7
+ data.tar.gz: b4d9901c7f64eb7aa931f097d7d04301c1b377d9dc1e5f15bbda8725d46b20835665002a025c7133f1f60cb8e5257c2317d718774e378568bc65e97da42e313b
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jsonapi-realizer
2
2
 
3
- - [![Build](http://img.shields.io/travis-ci/krainboltgreene/jsonapi-realizer.svg?style=flat-square)](https://travis-ci.org/krainboltgreene/jsonapi-realizer)
3
+ - [![Build](http://img.shields.io/travis-ci/krainboltgreene/jsonapi-realizer.rb.svg?style=flat-square)](https://travis-ci.org/krainboltgreene/jsonapi-realizer.rb)
4
4
  - [![Downloads](http://img.shields.io/gem/dtv/jsonapi-realizer.svg?style=flat-square)](https://rubygems.org/gems/jsonapi-realizer)
5
5
  - [![Version](http://img.shields.io/gem/v/jsonapi-realizer.svg?style=flat-square)](https://rubygems.org/gems/jsonapi-realizer)
6
6
 
@@ -21,7 +21,9 @@ class Profile < ApplicationRecord
21
21
  end
22
22
  ```
23
23
 
24
- *They don't have to be ActiveRecord* models, but we have built-in support for that library (adapter-based). Second you'll need some realizers:
24
+ *Note: They don't have to be ActiveRecord models, but we have built-in support for that library (adapter-based).*
25
+
26
+ Second you'll need some realizers:
25
27
 
26
28
  ``` ruby
27
29
  class PhotoRealizer
@@ -183,9 +185,14 @@ class PhotoRealizer
183
185
  end
184
186
  ```
185
187
 
186
- ### rails and jsonapi-realizer and jsonapi-serializers and pundit
188
+ ### rails
189
+
190
+ If you want to use jsonapi-realizer in development mode you'll want to turn on `eager_loading` (by setting it to `true` in `config/environments/development.rb`) or by adding `app/realizers` to the `eager_load_paths`.
191
+
187
192
 
188
- While this gem contains nothing specifically targeting Rails or pundit or [jsonapi-serializers](https://github.com/fotinakis/jsonapi-serializers) (a fantastic gem) I've already written some seamless integration code. This root controller will handle exceptions in a graceful way and also give you access to a clean interface for serializing:
193
+ ### rails and pundit and jsonapi-serializers
194
+
195
+ While this gem contains nothing specifically targeting rails or pundit or [jsonapi-serializers](https://github.com/fotinakis/jsonapi-serializers) (a fantastic gem) I've already written some seamless integration code. This root controller will handle exceptions in a graceful way and also give you access to a clean interface for serializing:
189
196
 
190
197
  ``` ruby
191
198
  module V1
@@ -333,10 +340,6 @@ Or install it yourself with:
333
340
 
334
341
  $ gem install jsonapi-realizer
335
342
 
336
- ### Rails
337
-
338
- There's nothing extremely special about a rails application, but if you want to use jsonapi-realizer in development mode you'll probably want to turn on `eager_loading` (by setting it to `true` in `config/environments/development.rb`) or by adding `app/realizers` to the `eager_load_paths`.
339
-
340
343
 
341
344
  ## Contributing
342
345
 
@@ -83,12 +83,23 @@ module JSONAPI
83
83
  end
84
84
 
85
85
  private def as_relationship(value)
86
- data = value.fetch("data")
87
- mapping = JSONAPI::Realizer.type_mapping.fetch(data.fetch("type"))
88
- mapping.adapter.find_via_call(
89
- mapping.model_class,
90
- data.fetch("id")
91
- )
86
+ if value.kind_of?(Array)
87
+ value.map do |member|
88
+ data = member.fetch("data")
89
+ mapping = JSONAPI::Realizer.type_mapping.fetch(data.fetch("type"))
90
+ mapping.adapter.find_via_call(
91
+ mapping.model_class,
92
+ data.fetch("id")
93
+ )
94
+ end
95
+ else
96
+ data = value.fetch("data")
97
+ mapping = JSONAPI::Realizer.type_mapping.fetch(data.fetch("type"))
98
+ mapping.adapter.find_via_call(
99
+ mapping.model_class,
100
+ data.fetch("id")
101
+ )
102
+ end
92
103
  end
93
104
 
94
105
  def includes
@@ -1,5 +1,5 @@
1
1
  module JSONAPI
2
2
  module Realizer
3
- VERSION = "4.1.0"
3
+ VERSION = "4.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi-realizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kurtis Rainbolt-Greene
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-03-25 00:00:00.000000000 Z
11
+ date: 2018-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,14 +112,32 @@ dependencies:
112
112
  name: activesupport
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - "~>"
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 4.0.0
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '4.1'
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 5.0.0
124
+ - - ">="
116
125
  - !ruby/object:Gem::Version
117
126
  version: '5.1'
118
127
  type: :runtime
119
128
  prerelease: false
120
129
  version_requirements: !ruby/object:Gem::Requirement
121
130
  requirements:
122
- - - "~>"
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: 4.0.0
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '4.1'
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: 5.0.0
140
+ - - ">="
123
141
  - !ruby/object:Gem::Version
124
142
  version: '5.1'
125
143
  description: A way to take json:api requests and turn them into models
@@ -182,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
200
  version: '0'
183
201
  requirements: []
184
202
  rubyforge_project:
185
- rubygems_version: 2.7.6
203
+ rubygems_version: 2.7.3
186
204
  signing_key:
187
205
  specification_version: 4
188
206
  summary: A way to take json:api requests and turn them into models