jsonapi_compliable 0.11.1 → 0.11.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/jsonapi/field_generator.rb +0 -0
- data/lib/jsonapi_compliable/resource.rb +2 -2
- data/lib/jsonapi_compliable/scoping/default_filter.rb +1 -1
- data/lib/jsonapi_compliable/scoping/extra_fields.rb +1 -1
- data/lib/jsonapi_compliable/scoping/filter.rb +24 -1
- data/lib/jsonapi_compliable/scoping/paginate.rb +1 -1
- data/lib/jsonapi_compliable/scoping/sort.rb +2 -1
- data/lib/jsonapi_compliable/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db73195ae7cc73877b7d3bf32fa81bb89f0e747
|
4
|
+
data.tar.gz: 186d279c3221ab57bf08ab86145bac235c621c17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df42aaa0b32e2fdb0aa6c1dd288fb93765e8d52bc48ba676751c280c96b1a6ee81348ec75bad9a2b08cd9e02e73e6905c10057ba8c69634cc2e39d788d68a0d4
|
7
|
+
data.tar.gz: d60190e16b515697be4b6167034815d1f265c753cb7e2bf57c9345f2a1d592b83f1a1b2cc9289750a6008f01be6daed66d8147047caaed09c4bf99894aa03b30
|
File without changes
|
@@ -487,7 +487,7 @@ module JsonapiCompliable
|
|
487
487
|
# @see .model
|
488
488
|
# @see Adapters::ActiveRecord#update
|
489
489
|
# @param [Hash] update_params The relevant attributes, including id and foreign keys
|
490
|
-
# @return [Object] an instance of the just-
|
490
|
+
# @return [Object] an instance of the just-updated model
|
491
491
|
def update(update_params)
|
492
492
|
adapter.update(model, update_params)
|
493
493
|
end
|
@@ -507,7 +507,7 @@ module JsonapiCompliable
|
|
507
507
|
# @see .model
|
508
508
|
# @see Adapters::ActiveRecord#destroy
|
509
509
|
# @param [String] id The +id+ of the relevant Model
|
510
|
-
# @return [Object] an instance of the just-
|
510
|
+
# @return [Object] an instance of the just-destroyed model
|
511
511
|
def destroy(id)
|
512
512
|
adapter.destroy(model, id)
|
513
513
|
end
|
@@ -41,7 +41,7 @@ module JsonapiCompliable
|
|
41
41
|
# specified in the adapter.
|
42
42
|
def filter_scope(filter, value)
|
43
43
|
if custom_scope = filter.values.first[:filter]
|
44
|
-
custom_scope.call(@scope, value)
|
44
|
+
custom_scope.call(@scope, value, resource.context)
|
45
45
|
else
|
46
46
|
resource.adapter.filter(@scope, filter.keys.first, value)
|
47
47
|
end
|
@@ -52,8 +52,31 @@ module JsonapiCompliable
|
|
52
52
|
filter = find_filter!(param_name.to_sym)
|
53
53
|
value = param_value
|
54
54
|
value = value.split(',') if value.is_a?(String) && value.include?(',')
|
55
|
+
value = normalize_string_values(value)
|
55
56
|
yield filter, value
|
56
57
|
end
|
57
58
|
end
|
59
|
+
|
60
|
+
# Convert a string of "true" to true, etc
|
61
|
+
#
|
62
|
+
# NB - avoid Array(value) here since we might want to
|
63
|
+
# return a single element instead of array
|
64
|
+
def normalize_string_values(value)
|
65
|
+
if value.is_a?(Array)
|
66
|
+
value.map { |v| normalize_string_value(v) }
|
67
|
+
else
|
68
|
+
normalize_string_value(value)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def normalize_string_value(value)
|
73
|
+
case value
|
74
|
+
when 'true' then true
|
75
|
+
when 'false' then false
|
76
|
+
when 'nil', 'null' then nil
|
77
|
+
else
|
78
|
+
value
|
79
|
+
end
|
80
|
+
end
|
58
81
|
end
|
59
82
|
end
|
@@ -31,7 +31,8 @@ module JsonapiCompliable
|
|
31
31
|
# @return the scope we are chaining/modifying
|
32
32
|
def apply_custom_scope
|
33
33
|
each_sort do |attribute, direction|
|
34
|
-
@scope = custom_scope
|
34
|
+
@scope = custom_scope
|
35
|
+
.call(@scope, attribute, direction, resource.context)
|
35
36
|
end
|
36
37
|
@scope
|
37
38
|
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.2
|
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-
|
12
|
+
date: 2018-03-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jsonapi-serializable
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- gemfiles/rails_4.gemfile
|
203
203
|
- gemfiles/rails_5.gemfile
|
204
204
|
- jsonapi_compliable.gemspec
|
205
|
+
- lib/generators/jsonapi/field_generator.rb
|
205
206
|
- lib/generators/jsonapi/resource_generator.rb
|
206
207
|
- lib/generators/jsonapi/templates/application_resource.rb.erb
|
207
208
|
- lib/generators/jsonapi/templates/controller.rb.erb
|