jsonapi_compliable 0.10.9 → 0.11.0

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
  SHA1:
3
- metadata.gz: c57344ec75f9fa96fd13ebcf83abe1ca58d1d20e
4
- data.tar.gz: cf942fd528a49bbad613692b4d6db297742c8224
3
+ metadata.gz: cdce2b040460bc3c66f0aa2a869e5be239cef593
4
+ data.tar.gz: 37e97590487dbd9eca8edc3157174f4826e79bba
5
5
  SHA512:
6
- metadata.gz: 07dbfa3e4559cc419343479ed870d9264e66b6a6c9c34eac5384b49e2259ac1ecd8d12cbd098fa03dbcb34b5269617fd20fa598e1fb797be62d7a1ab0a89ce2e
7
- data.tar.gz: 3ade1417f03913ad2df35d6447a19c15fe4eb302e3effe1c00b9822fc376accb8d482e20dcbaaaa366204f5c44bdc82968f469d4bd8db79029a6165ed78e6f85
6
+ metadata.gz: 0462e8f0e8745dcefafce80dd8c605254b7b28731a14d6d0c5fdd4cb2cae0575c22dc83d199b00269bbb78d77a2a22d6744b515bf05d4ad24fa0e845529d33e4
7
+ data.tar.gz: 6cbacdb485370394b01d8dd80a031b254e0712e182c833671a04c39d62037e2b61e79f9fd084b57e0ebd90cc3b279eb282ae42c0fea5e99f3dc93b817d1c9e7e
data/Appraisals CHANGED
@@ -1,11 +1,11 @@
1
1
  appraise "rails-4" do
2
2
  gem "rails", "~> 4.1"
3
- gem 'jsonapi-rails', '~> 0.2.0', require: 'jsonapi/rails'
3
+ gem 'jsonapi-rails', '~> 0.3.1', require: 'jsonapi/rails'
4
4
  gem 'rspec-rails'
5
5
  end
6
6
 
7
7
  appraise "rails-5" do
8
8
  gem "rails", "~> 5.0"
9
- gem 'jsonapi-rails', '~> 0.2.0', require: 'jsonapi/rails'
9
+ gem 'jsonapi-rails', '~> 0.3.1', require: 'jsonapi/rails'
10
10
  gem 'rspec-rails'
11
11
  end
data/README.md CHANGED
@@ -8,6 +8,35 @@
8
8
 
9
9
  Supported Rails versions: >= 4.1
10
10
 
11
+ ### Upgrading to 0.11.x
12
+
13
+ Due to a backwards-incompatibility introduced in the underlying
14
+ [jsonapi-rb](http://jsonapi-rb.org) gem, specifying custom serializers
15
+ now works slightly differently.
16
+
17
+ Before:
18
+
19
+ ```ruby
20
+ # app/serializers/serializable_post.rb
21
+
22
+ has_many :comments, class: SerializableSpecialComment
23
+ ```
24
+
25
+ and/or
26
+
27
+ ```ruby
28
+ render_jsonapi(post, class: SerializableSpecialPost)
29
+ ```
30
+
31
+ This is now all handled at the controller level:
32
+
33
+ ```ruby
34
+ render_jsonapi(post, class: {
35
+ Post: SerializableSpecialPost,
36
+ Comment: SerializableSpecialComment
37
+ })
38
+ ```
39
+
11
40
  ### Upgrading to 0.10
12
41
 
13
42
  `sideload_whitelist` has been moved from the resource to the controller:
@@ -3,15 +3,15 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 4.1"
6
- gem "jsonapi-rails", "~> 0.2.0", :require => "jsonapi/rails"
6
+ gem "jsonapi-rails", "~> 0.3.1", require: "jsonapi/rails"
7
7
  gem "rspec-rails"
8
8
 
9
9
  group :test do
10
10
  gem "pry"
11
- gem "pry-byebug", :platform => [:mri]
11
+ gem "pry-byebug", platform: [:mri]
12
12
  gem "appraisal"
13
13
  gem "guard"
14
14
  gem "guard-rspec"
15
15
  end
16
16
 
17
- gemspec :path => "../"
17
+ gemspec path: "../"
@@ -3,15 +3,15 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 5.0"
6
- gem "jsonapi-rails", "~> 0.2.0", :require => "jsonapi/rails"
6
+ gem "jsonapi-rails", "~> 0.3.1", require: "jsonapi/rails"
7
7
  gem "rspec-rails"
8
8
 
9
9
  group :test do
10
10
  gem "pry"
11
- gem "pry-byebug", :platform => [:mri]
11
+ gem "pry-byebug", platform: [:mri]
12
12
  gem "appraisal"
13
13
  gem "guard"
14
14
  gem "guard-rspec"
15
15
  end
16
16
 
17
- gemspec :path => "../"
17
+ gemspec path: "../"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  # Pinning this version until backwards-incompatibility is addressed
21
- spec.add_dependency 'jsonapi-serializable', '~> 0.2.0'
21
+ spec.add_dependency 'jsonapi-serializable', '~> 0.3.0'
22
22
 
23
23
  spec.add_development_dependency "activerecord", ['>= 4.1', '< 6']
24
24
  spec.add_development_dependency "kaminari", '~> 0.17'
@@ -290,7 +290,7 @@ module JsonapiCompliable
290
290
 
291
291
  def perform_render_jsonapi(opts)
292
292
  # TODO(beauby): Reuse renderer.
293
- JSONAPI::Serializable::SuccessRenderer.new
293
+ JSONAPI::Serializable::Renderer.new
294
294
  .render(opts.delete(:jsonapi), opts).to_json
295
295
  end
296
296
 
@@ -6,7 +6,14 @@ module JsonapiCompliable
6
6
  def self.generate(object, query_hash, overrides = {})
7
7
  resolved = object.respond_to?(:resolve) ? object.resolve : object
8
8
 
9
+ inferrer = ::Hash.new do |h, k|
10
+ names = k.to_s.split('::')
11
+ klass = names.pop
12
+ h[k] = [*names, "Serializable#{klass}"].join('::').safe_constantize
13
+ end
14
+
9
15
  options = {}
16
+ options[:class] = inferrer
10
17
  options[:include] = query_hash[:include]
11
18
  options[:jsonapi] = resolved
12
19
  options[:fields] = query_hash[:fields]
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.10.9"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi_compliable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.9
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Richmond
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-01-04 00:00:00.000000000 Z
12
+ date: 2018-01-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 0.2.0
20
+ version: 0.3.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: 0.2.0
27
+ version: 0.3.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement