jsonapi_compliable 0.11.3 → 0.11.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
  SHA1:
3
- metadata.gz: f09a3b7abaad7968009175f50671ba51a32e42c0
4
- data.tar.gz: d0a5de6083ae24be24380ff620fb10aa8ce0e3d6
3
+ metadata.gz: a808d8ba133336b8d4064dfd4e4419edf13f04b8
4
+ data.tar.gz: c445ae7db757752acc75d9f3116b9f4d0a53dc81
5
5
  SHA512:
6
- metadata.gz: 0aa3c2b725818ef5ef30e328a98dc1595ffdace212cf7addf5c15db2b19e4f5ee48f17cde4b26358ee0a4ab42a94e29d5bda032c4e58ffbad367610135298268
7
- data.tar.gz: 9f0469e4fb7ff9b697729e02a5d616a6551beb3d55374fa6eeb6ba645a7a22e431f9651cb708f63adae0c3a8d2f6a8fb20b80bda83549ca780c761a7e9de78b4
6
+ metadata.gz: 93690be0d49a991b134bd235c458c2fa381802d93b488f7e910cb481f0087b06752ef3141fdf446e989222bcc483703d21fd7cd1abe021ce5037bf71b3d3bbee
7
+ data.tar.gz: db0bac90c114efc88aa64347304a83adf035a76e461157cfa0a59eb83fc72d23da5bf43fabea7373b67c880aa0028dc7ae5a06e9033dd16a40467da5e5a34080
@@ -0,0 +1,14 @@
1
+ # https://robots.thoughtbot.com/mygem-configure-block
2
+ module JsonapiCompliable
3
+ class Configuration
4
+ # @return [Boolean] Should we raise when the client requests a relationship not defined on the server?
5
+ # Defaults to true.
6
+ attr_accessor :raise_on_missing_sideload
7
+
8
+ # Set defaults
9
+ # @api private
10
+ def initialize
11
+ @raise_on_missing_sideload = true
12
+ end
13
+ end
14
+ end
@@ -82,12 +82,15 @@ module JsonapiCompliable
82
82
  includes.each_pair do |name, nested|
83
83
  sideload = @resource.sideload(name)
84
84
 
85
- unless sideload
86
- raise JsonapiCompliable::Errors::InvalidInclude.new(name, @resource.type)
85
+ if sideload.nil?
86
+ if JsonapiCompliable.config.raise_on_missing_sideload
87
+ raise JsonapiCompliable::Errors::InvalidInclude
88
+ .new(name, @resource.type)
89
+ end
90
+ else
91
+ namespace = Util::Sideload.namespace(@namespace, sideload.name)
92
+ sideload.resolve(results, @query, namespace)
87
93
  end
88
-
89
- namespace = Util::Sideload.namespace(@namespace, sideload.name)
90
- sideload.resolve(results, @query, namespace)
91
94
  end
92
95
  end
93
96
 
@@ -1,3 +1,3 @@
1
1
  module JsonapiCompliable
2
- VERSION = "0.11.3"
2
+ VERSION = "0.11.4"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require "jsonapi_compliable/version"
2
+ require "jsonapi_compliable/configuration"
2
3
  require "jsonapi_compliable/errors"
3
4
  require "jsonapi_compliable/resource"
4
5
  require "jsonapi_compliable/query"
@@ -64,4 +65,18 @@ module JsonapiCompliable
64
65
  self.context = prior
65
66
  end
66
67
  end
68
+
69
+ def self.config
70
+ @config ||= Configuration.new
71
+ end
72
+
73
+ # @example
74
+ # JsonapiCompliable.configure do |c|
75
+ # c.raise_on_missing_sideload = false
76
+ # end
77
+ #
78
+ # @see Configuration
79
+ def self.configure
80
+ yield config
81
+ end
67
82
  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.11.3
4
+ version: 0.11.4
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-04-13 00:00:00.000000000 Z
12
+ date: 2018-04-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jsonapi-serializable
@@ -220,6 +220,7 @@ files:
220
220
  - lib/jsonapi_compliable/adapters/active_record_sideloading.rb
221
221
  - lib/jsonapi_compliable/adapters/null.rb
222
222
  - lib/jsonapi_compliable/base.rb
223
+ - lib/jsonapi_compliable/configuration.rb
223
224
  - lib/jsonapi_compliable/deserializer.rb
224
225
  - lib/jsonapi_compliable/errors.rb
225
226
  - lib/jsonapi_compliable/extensions/boolean_attribute.rb