jsonapi_compliable 0.11.13 → 0.11.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/jsonapi_compliable/errors.rb +14 -0
- data/lib/jsonapi_compliable/resource.rb +2 -1
- data/lib/jsonapi_compliable/scoping/filter.rb +1 -0
- data/lib/jsonapi_compliable/scoping/filterable.rb +14 -0
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85cb483d105b4de74832a99fefe27def18abf39c
|
4
|
+
data.tar.gz: df674dec125d95d7a53850cffa4505cc25dc7cc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d8ccc89afff5695bb27ab30b1fa07a209ec349fb68f0c07042a152dc3b63a7775235bc20386ca75cae0c0a574564faf4a0316815a7226c4c0181beb5e431a82
|
7
|
+
data.tar.gz: 935e966df8bd96148ff5cadd32bee84257b723f1f7872236a8e2d7d32effc54e8e07ee93c9b5b8532240502a6422c34547c20149864bf30be67d2ad40450a70a
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.4.1
|
@@ -47,5 +47,19 @@ module JsonapiCompliable
|
|
47
47
|
|
48
48
|
class RecordNotFound < StandardError
|
49
49
|
end
|
50
|
+
|
51
|
+
class RequiredFilter < StandardError
|
52
|
+
def initialize(attributes)
|
53
|
+
@attributes = Array(attributes)
|
54
|
+
end
|
55
|
+
|
56
|
+
def message
|
57
|
+
if @attributes.length > 1
|
58
|
+
"The required filters \"#{@attributes.join(', ')}\" were not provided"
|
59
|
+
else
|
60
|
+
"The required filter \"#{@attributes[0]}\" was not provided"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
50
64
|
end
|
51
65
|
end
|
@@ -28,6 +28,7 @@ module JsonapiCompliable
|
|
28
28
|
# aliases. If valid, call either the default or custom filtering logic.
|
29
29
|
# @return the scope we are chaining/modifying
|
30
30
|
def apply
|
31
|
+
raise JsonapiCompliable::Errors::RequiredFilter.new(missing_required_filters) unless required_filters_provided?
|
31
32
|
each_filter do |filter, value|
|
32
33
|
@scope = filter_scope(filter, value)
|
33
34
|
end
|
@@ -23,5 +23,19 @@ module JsonapiCompliable
|
|
23
23
|
def filter_param
|
24
24
|
query_hash[:filter]
|
25
25
|
end
|
26
|
+
|
27
|
+
def missing_required_filters
|
28
|
+
required_filters.keys - filter_param.keys
|
29
|
+
end
|
30
|
+
|
31
|
+
def required_filters
|
32
|
+
resource.filters.select do |_name, opts|
|
33
|
+
opts[:required].respond_to?(:call) ? opts[:required].call(resource.context) : opts[:required]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def required_filters_provided?
|
38
|
+
missing_required_filters.empty?
|
39
|
+
end
|
26
40
|
end
|
27
41
|
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.
|
4
|
+
version: 0.11.14
|
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-05-
|
12
|
+
date: 2018-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|