json_api_client 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/json_api_client/associations/base_association.rb +1 -1
- data/lib/json_api_client/associations/belongs_to.rb +7 -1
- data/lib/json_api_client/helpers.rb +2 -1
- data/lib/json_api_client/helpers/uri.rb +9 -0
- data/lib/json_api_client/query/requestor.rb +2 -5
- data/lib/json_api_client/resource.rb +5 -1
- data/lib/json_api_client/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 441f2bb5cf8f6fd819fda9b1b06282a7295b314c
|
4
|
+
data.tar.gz: 4dafa2d5bdf7a8b8aecad456638c704f609719bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7ef003297a74702c6425a6869c30b204cc66996cd579ba46f462607eb1295a37134155160638d301a035d31fc9151d58d465890e5bf406026dff41853106363
|
7
|
+
data.tar.gz: 1d67ac769d524ed852e9a675b9b5e831c6f6224c0c8f4ab0666f105f010eadf735c6497d3fb5f5ec2e09700869d072c94df9b181ce67101b3bff775550d7b021
|
@@ -11,6 +11,7 @@ module JsonApiClient
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class Association < BaseAssociation
|
14
|
+
include Helpers::URI
|
14
15
|
def param
|
15
16
|
:"#{attr_name}_id"
|
16
17
|
end
|
@@ -18,7 +19,12 @@ module JsonApiClient
|
|
18
19
|
def to_prefix_path
|
19
20
|
"#{attr_name.to_s.pluralize}/%{#{param}}"
|
20
21
|
end
|
22
|
+
|
23
|
+
def set_prefix_path(attrs)
|
24
|
+
attrs[param] = encode_part(attrs[param]) if attrs.key?(param)
|
25
|
+
to_prefix_path % attrs
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
24
|
-
end
|
30
|
+
end
|
@@ -3,5 +3,6 @@ module JsonApiClient
|
|
3
3
|
autoload :Callbacks, 'json_api_client/helpers/callbacks'
|
4
4
|
autoload :Dirty, 'json_api_client/helpers/dirty'
|
5
5
|
autoload :DynamicAttributes, 'json_api_client/helpers/dynamic_attributes'
|
6
|
+
autoload :URI, 'json_api_client/helpers/uri'
|
6
7
|
end
|
7
|
-
end
|
8
|
+
end
|
@@ -2,6 +2,7 @@ module JsonApiClient
|
|
2
2
|
module Query
|
3
3
|
class Requestor
|
4
4
|
extend Forwardable
|
5
|
+
include Helpers::URI
|
5
6
|
|
6
7
|
def initialize(klass)
|
7
8
|
@klass = klass
|
@@ -49,16 +50,12 @@ module JsonApiClient
|
|
49
50
|
|
50
51
|
def resource_path(parameters)
|
51
52
|
if resource_id = parameters[klass.primary_key]
|
52
|
-
File.join(klass.path(parameters),
|
53
|
+
File.join(klass.path(parameters), encode_part(resource_id))
|
53
54
|
else
|
54
55
|
klass.path(parameters)
|
55
56
|
end
|
56
57
|
end
|
57
58
|
|
58
|
-
def encoded(part)
|
59
|
-
Addressable::URI.encode_component(part, Addressable::URI::CharacterClasses::UNRESERVED)
|
60
|
-
end
|
61
|
-
|
62
59
|
def request(type, path, params)
|
63
60
|
klass.parser.parse(klass, connection.run(type, path, params, klass.custom_headers))
|
64
61
|
end
|
@@ -119,7 +119,7 @@ module JsonApiClient
|
|
119
119
|
parts = [resource_path]
|
120
120
|
if params && _prefix_path.present?
|
121
121
|
path_params = params.delete(:path) || params
|
122
|
-
parts.unshift(
|
122
|
+
parts.unshift(_set_prefix_path(path_params.symbolize_keys))
|
123
123
|
else
|
124
124
|
parts.unshift(_prefix_path)
|
125
125
|
end
|
@@ -266,6 +266,10 @@ module JsonApiClient
|
|
266
266
|
_belongs_to_associations.map(&:to_prefix_path).join("/")
|
267
267
|
end
|
268
268
|
|
269
|
+
def _set_prefix_path(attrs)
|
270
|
+
_belongs_to_associations.map { |a| a.set_prefix_path(attrs) }.join("/")
|
271
|
+
end
|
272
|
+
|
269
273
|
def _new_scope
|
270
274
|
query_builder.new(self)
|
271
275
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- lib/json_api_client/helpers/callbacks.rb
|
132
132
|
- lib/json_api_client/helpers/dirty.rb
|
133
133
|
- lib/json_api_client/helpers/dynamic_attributes.rb
|
134
|
+
- lib/json_api_client/helpers/uri.rb
|
134
135
|
- lib/json_api_client/implementation.rb
|
135
136
|
- lib/json_api_client/included_data.rb
|
136
137
|
- lib/json_api_client/linking.rb
|