json_api_client 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -1
- data/lib/json_api_client/helpers/queryable.rb +2 -4
- data/lib/json_api_client/query/base.rb +4 -0
- data/lib/json_api_client/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e53d7f45abf5b0e493ddb17782ef7eb168889245
|
4
|
+
data.tar.gz: ccefe013c990805cec13b57fb2420d2e929ed776
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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.
|
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: []
|