jsonapi.rb 2.0.0 → 2.0.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: 2192bbffc57d4ecbe419a90e25728951db4464c5f299e8866afefe72fa393cad
4
- data.tar.gz: f7f83b43169207e7cf6d06e6e99cc8c8f705de09c4c83ff9dba5238540577a9e
3
+ metadata.gz: d531366279855044f83d35f4526a72156c711895290ab4dbce73f1c7615f1079
4
+ data.tar.gz: 63bd2be61a78d79a64bc739cbb492ee75a9e2f90a95389d55f133a2565627abb
5
5
  SHA512:
6
- metadata.gz: 577c2b0d1801ef2191c25925e407449ff12ba95d7fc5c8433fcbb2b20e532a1b7a51a884f147c5042c38ec27ca9eed6567bfd746aad4ad8895b7a3f90e9043b1
7
- data.tar.gz: f6ca1bc49fd89c1ea942f3c047234d76c4fa1d7604bd06aa5d67c43dad93603cb19e6c542ec13837d1db5e3fbe923ec4799fd865c96c08822dcab7cb160d7f7e
6
+ metadata.gz: e602d6c993cd0259ac0b81c57eca16aee525f53ed0e5b4ac8014a0cb500528d579541375ce7735f0f191f3f732af9178ebbfdf7d4615eb967cfb244d1796cd36
7
+ data.tar.gz: 46a957ded4247be1607f6a4d84246da42a44fe41c58c55e2a34a914e958a28731531bc5e8a3f0d0141f571e17dce19c9c1f6f58845fc3e7db874d763dfcaffbb
@@ -3,7 +3,6 @@ begin
3
3
  require 'ransack'
4
4
  require_relative 'patches'
5
5
  rescue LoadError
6
- warn('Install `ransack` gem before using `JSONAPI::Filtering`!')
7
6
  end
8
7
 
9
8
  # Filtering and sorting support
data/lib/jsonapi/rails.rb CHANGED
@@ -37,7 +37,7 @@ module JSONAPI
37
37
  # @return [NilClass]
38
38
  def self.add_errors_renderer!
39
39
  ActionController::Renderers.add(:jsonapi_errors) do |resource, options|
40
- self.content_type ||= Mime[:jsonapi]
40
+ self.content_type = Mime[:jsonapi] if self.media_type.nil?
41
41
 
42
42
  many = JSONAPI::Rails.is_collection?(resource, options[:is_collection])
43
43
  resource = [resource] unless many
@@ -90,7 +90,7 @@ module JSONAPI
90
90
  # @return [NilClass]
91
91
  def self.add_renderer!
92
92
  ActionController::Renderers.add(:jsonapi) do |resource, options|
93
- self.content_type ||= Mime[:jsonapi]
93
+ self.content_type = Mime[:jsonapi] if self.media_type.nil?
94
94
 
95
95
  JSONAPI_METHODS_MAPPING.to_a[0..1].each do |opt, method_name|
96
96
  next unless respond_to?(method_name, true)
@@ -100,7 +100,7 @@ module JSONAPI
100
100
  # If it's an empty collection, return it directly.
101
101
  many = JSONAPI::Rails.is_collection?(resource, options[:is_collection])
102
102
  if many && !resource.any?
103
- return options.slice(:meta, :links).merge(data: []).to_json
103
+ return options.slice(:meta, :links).compact.merge(data: []).to_json
104
104
  end
105
105
 
106
106
  JSONAPI_METHODS_MAPPING.to_a[2..-1].each do |opt, method_name|
@@ -1,3 +1,3 @@
1
1
  module JSONAPI
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsonapi.rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas Suscov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-21 00:00:00.000000000 Z
11
+ date: 2022-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jsonapi-serializer
@@ -265,7 +265,7 @@ homepage: https://github.com/stas/jsonapi.rb
265
265
  licenses:
266
266
  - MIT
267
267
  metadata: {}
268
- post_install_message:
268
+ post_install_message: Install manually `ransack` gem before using `JSONAPI::Filtering`!
269
269
  rdoc_options: []
270
270
  require_paths:
271
271
  - lib