json_api_client 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cd3a5cd09cfe62026ca92b0f96bdf96bbbf448fa
4
- data.tar.gz: fff1f331e95db8247b97220be4be16b8d5b89b2a
3
+ metadata.gz: e53d7f45abf5b0e493ddb17782ef7eb168889245
4
+ data.tar.gz: ccefe013c990805cec13b57fb2420d2e929ed776
5
5
  SHA512:
6
- metadata.gz: 2c4abe201352dd98b06d362c88a0b44ef57a048000835bce3d43524bce91dfccba953d238de9329ac0f2869d30fe4ed8e6d358fc92675ca99f5c7f2546c62b51
7
- data.tar.gz: f5e3c21c58d71b682372da6c550030c8176a3d56d9d6c7f7dfb8a167031f21d1a38335c359ceb9a7ce519e5df39c673b30c5b17ad279584beeb9c0828d9a63aa
6
+ metadata.gz: a82e7570409337b1107ec52aade2cd09be667fe3111b5a96be50a77766940570f68722b019e9505c85d4b32df3528eec1300c78b4591dc7882f3e34507857287
7
+ data.tar.gz: 7b7b843d25a492069fb99bf77a7252c03d37e0bdae92c433e012ff4ef10a3d5134e3e8713a0d435e2afc15a74d43170decbf64c11c0118cfd63466332cedbcfd
data/README.md CHANGED
@@ -42,7 +42,7 @@ u.accounts
42
42
  => MyApi::Account.where(user_id: u.id).all
43
43
  ```
44
44
 
45
- ## Connection options
45
+ ## Connection Options
46
46
 
47
47
  You can configure your connection using Faraday middleware. In general, you'll want
48
48
  to do this in a base model that all your resources inherit from:
@@ -65,6 +65,25 @@ module MyApi
65
65
  end
66
66
  ```
67
67
 
68
+ ## Custom Connection
69
+
70
+ You can configure your API client to use a custom connection that implementes the `execute` instance method. It should return data that your parser can handle.
71
+
72
+ ```
73
+ class NullConnection
74
+ def initialize(*args)
75
+ end
76
+
77
+ def execute(query)
78
+ end
79
+ end
80
+
81
+ class CustomConnectionResource < TestResource
82
+ self.connection_class = NullConnection
83
+ end
84
+
85
+ ```
86
+
68
87
  ## Custom Parser
69
88
 
70
89
  You can configure your API client to use a custom parser that implements the `parse` class method. It should return a `JsonApiClient::ResultSet` instance. You can use it by setting the parser attribute on your model:
@@ -8,6 +8,8 @@ module JsonApiClient
8
8
  extend Forwardable
9
9
  def_delegators :new_scope, :where, :order, :includes, :all, :paginate, :page, :first
10
10
  end
11
+ class_attribute :connection_class
12
+ self.connection_class = Connection
11
13
  end
12
14
 
13
15
  module ClassMethods
@@ -28,10 +30,6 @@ module JsonApiClient
28
30
  def build_connection
29
31
  connection_class.new(site)
30
32
  end
31
-
32
- def connection_class
33
- Connection
34
- end
35
33
  end
36
34
 
37
35
  end
@@ -22,6 +22,10 @@ module JsonApiClient
22
22
  @params = args.dup
23
23
  end
24
24
 
25
+ def inspect
26
+ "method: #{request_method}; path: #{path}; params: #{params}, headers: #{headers}"
27
+ end
28
+
25
29
  end
26
30
  end
27
31
  end
@@ -1,3 +1,3 @@
1
1
  module JsonApiClient
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  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: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Ching
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: mocha
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Build client libraries compliant with specification defined by jsonapi.org
56
70
  email: ching.jeff@gmail.com
57
71
  executables: []