json_api_client 1.0.0.beta4 → 1.0.0.beta5
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/helpers/custom_headers.rb +31 -0
- data/lib/json_api_client/helpers/relatable.rb +0 -6
- data/lib/json_api_client/helpers/serializable.rb +7 -1
- data/lib/json_api_client/helpers.rb +1 -0
- data/lib/json_api_client/query/requestor.rb +1 -1
- data/lib/json_api_client/resource.rb +1 -0
- data/lib/json_api_client/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf70c1b87181f83e74d93e6711ff52d3ba70cf49
|
4
|
+
data.tar.gz: 065d5cf0d8559fbe051f312643763f0b508dd351
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8bf495991e43b1e034a4e23c915af9b18130c9a58fe1882927f5ffa9aac3b33ecd1b66c658c3f8ece03164579adcc46234356487a3e1e2aa15871ff280892577
|
7
|
+
data.tar.gz: e588c5bec7188484fa1f215660187cc69acd23dc5c8431d34bf58fc4d54a0aafd75748318f8c1bb06291bdddad73a97388317c24c0a9cca75911c4d3f980fb4c
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module JsonApiClient
|
2
|
+
module Helpers
|
3
|
+
module CustomHeaders
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
module ClassMethods
|
7
|
+
def with_headers(headers)
|
8
|
+
self.custom_headers = headers
|
9
|
+
yield
|
10
|
+
ensure
|
11
|
+
self.custom_headers = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def custom_headers
|
15
|
+
header_store
|
16
|
+
end
|
17
|
+
|
18
|
+
def custom_headers=(headers)
|
19
|
+
header_store.replace(headers)
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def header_store
|
25
|
+
Thread.current["json_api_client-#{resource_name}"] ||= {}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -24,12 +24,6 @@ module JsonApiClient
|
|
24
24
|
}
|
25
25
|
end
|
26
26
|
|
27
|
-
def attributes
|
28
|
-
super.tap do |attrs|
|
29
|
-
attrs.merge!(relationships: relationships.attributes) if relationships.present?
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
27
|
def method_missing(method, *args)
|
34
28
|
return super unless relationships and relationships.has_attribute?(method) and result_set.included
|
35
29
|
result_set.included.data_for(method, relationships[method])
|
@@ -13,10 +13,16 @@ module JsonApiClient
|
|
13
13
|
relationships.serializable_hash.tap do |r|
|
14
14
|
h['relationships'] = r unless r.empty?
|
15
15
|
end
|
16
|
-
h['attributes'] =
|
16
|
+
h['attributes'] = attributes_for_serialization
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
protected
|
21
|
+
|
22
|
+
def attributes_for_serialization
|
23
|
+
attributes.except(*self.class.read_only_attributes)
|
24
|
+
end
|
25
|
+
|
20
26
|
end
|
21
27
|
end
|
22
28
|
end
|
@@ -3,6 +3,7 @@ module JsonApiClient
|
|
3
3
|
autoload :Associable, 'json_api_client/helpers/associable'
|
4
4
|
autoload :Attributable, 'json_api_client/helpers/attributable'
|
5
5
|
autoload :CustomEndpoints, 'json_api_client/helpers/custom_endpoints'
|
6
|
+
autoload :CustomHeaders, 'json_api_client/helpers/custom_headers'
|
6
7
|
autoload :DynamicAttributes, 'json_api_client/helpers/dynamic_attributes'
|
7
8
|
autoload :Initializable, 'json_api_client/helpers/initializable'
|
8
9
|
autoload :Linkable, 'json_api_client/helpers/linkable'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Ching
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/json_api_client/helpers/associable.rb
|
117
117
|
- lib/json_api_client/helpers/attributable.rb
|
118
118
|
- lib/json_api_client/helpers/custom_endpoints.rb
|
119
|
+
- lib/json_api_client/helpers/custom_headers.rb
|
119
120
|
- lib/json_api_client/helpers/dynamic_attributes.rb
|
120
121
|
- lib/json_api_client/helpers/initializable.rb
|
121
122
|
- lib/json_api_client/helpers/linkable.rb
|
@@ -171,8 +172,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
171
172
|
version: 1.3.1
|
172
173
|
requirements: []
|
173
174
|
rubyforge_project:
|
174
|
-
rubygems_version: 2.
|
175
|
+
rubygems_version: 2.2.2
|
175
176
|
signing_key:
|
176
177
|
specification_version: 4
|
177
178
|
summary: Build client libraries compliant with specification defined by jsonapi.org
|
178
179
|
test_files: []
|
180
|
+
has_rdoc:
|