json_api_client 1.0.0.beta4 → 1.0.0.beta5

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: 6a4cf7888d664d4668f98705059cdffcead9c2b7
4
- data.tar.gz: 454e3c488bbcfe07799ecdbb7bb721a6c62801e7
3
+ metadata.gz: cf70c1b87181f83e74d93e6711ff52d3ba70cf49
4
+ data.tar.gz: 065d5cf0d8559fbe051f312643763f0b508dd351
5
5
  SHA512:
6
- metadata.gz: cb67e1ab20c2cd63d2aeaa72a2b2ff7682d9d34fd82303a9acbe62c1ad535a5606cbacf0e35c8503a7e89c9726f13681c38b5603ad77f174c8e4ea587aae4311
7
- data.tar.gz: 609d93e6f8c0b63fb04bd4215a1e996085e8ecada6b4620a3591f764e75c47493e1fb483a15f6e8b582518b408aa2d80196084c7cc5e669bcdc17a9ba974df77
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'] = attributes.except(*self.class.read_only_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'
@@ -60,7 +60,7 @@ module JsonApiClient
60
60
  end
61
61
 
62
62
  def request(type, path, params)
63
- klass.parse(connection.run(type, path, params))
63
+ klass.parse(connection.run(type, path, params, klass.custom_headers))
64
64
  end
65
65
 
66
66
  end
@@ -34,6 +34,7 @@ module JsonApiClient
34
34
  include Helpers::Schemable
35
35
  include Helpers::Paginatable
36
36
  include Helpers::Requestable
37
+ include Helpers::CustomHeaders
37
38
 
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "1.0.0.beta4"
2
+ VERSION = "1.0.0.beta5"
3
3
  end
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.beta4
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 00:00:00.000000000 Z
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.4.5
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: