json_api_model 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +49 -3
- data/lib/json_api_model/result_set.rb +1 -1
- data/lib/json_api_model/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3324fc4a9bc44c2e4f35bb8bfc07c85fa37d9b9
|
4
|
+
data.tar.gz: 8b131250bc286d8c6e6e7fbe3c47064d65f63942
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7338edaeb52f641a1b942c8d603c81274de36f91f9d4fd25b3d87b9d920b11baf240b4d0e829e2c0e737cbc02b7c313d2d9faa7177e83996822a70185e97ab8
|
7
|
+
data.tar.gz: 99f5989402ddff1c256cb6753347356e0f8fb7945d371e4993866c3d700bea5f3bbf06f7fa271b330359b1c7602cdacbe09119e01115187635b29d46a3319dc4
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# JsonApiModel
|
2
2
|
|
3
|
-
|
3
|
+
Much like `ActiveRecord` is an ORM on top of your database, [`JSON API Client`](https://github.com/JsonApiClient/json_api_client) is an ORM specific to a service. This gem is the `app/models/` on top of `json_api_client`.
|
4
4
|
|
5
|
-
|
5
|
+
Yes, you can put business in the client, but if you need to distrubute the gem, you will want that to live somewhere else. This gem provides a thin wrapper layer to let you do that.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,7 +22,53 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
TODO:
|
25
|
+
TODO: finish writing this
|
26
|
+
|
27
|
+
Sample Base Class
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
module MyService
|
31
|
+
class Base < JsonApiModel::Model
|
32
|
+
|
33
|
+
wraps MyService::Client::Base
|
34
|
+
|
35
|
+
# delegates connection options to the Client::Base without having to modify the gem
|
36
|
+
self.connection do | conn |
|
37
|
+
conn.use Faraday::Response::Logger, Rails.logger
|
38
|
+
|
39
|
+
conn.faraday.options.merge!(
|
40
|
+
open_timeout: 5,
|
41
|
+
timeout: 5
|
42
|
+
)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Inherited Class
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
module MySerive
|
52
|
+
class MyModel < Base
|
53
|
+
wraps MyService::Client::MyModel
|
54
|
+
|
55
|
+
def instanece_level_business
|
56
|
+
42
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
In the controller
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
class WhateversController < ApplicationController
|
66
|
+
def index
|
67
|
+
render json: MyService::MyModel.where( request.query_parameters ).all.as_json
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
26
72
|
|
27
73
|
## Development
|
28
74
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_api_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Orlov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|