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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e8108fc0f24c943231c25e571dd4e53bbdd7c81b
4
- data.tar.gz: 514bc267aaea9904075f23c714e997ad7c6a3632
3
+ metadata.gz: b3324fc4a9bc44c2e4f35bb8bfc07c85fa37d9b9
4
+ data.tar.gz: 8b131250bc286d8c6e6e7fbe3c47064d65f63942
5
5
  SHA512:
6
- metadata.gz: 280163fa58e09398bf0798928a81040d178a3d35e202e2423b136ebde61cc0bae6e2ed4f1d48c1d25909ed81ee744ba47206aede851e6ab1292f7969ad789082
7
- data.tar.gz: 5d01cb61d2fdf30de41080617bdc73d61b332b09d5d53942934d388351fb3839335afb65589251b07c62136ddd204bb82b0655b7db59c7b9cde2cc7f3e07bb6d
6
+ metadata.gz: f7338edaeb52f641a1b942c8d603c81274de36f91f9d4fd25b3d87b9d920b11baf240b4d0e829e2c0e737cbc02b7c313d2d9faa7177e83996822a70185e97ab8
7
+ data.tar.gz: 99f5989402ddff1c256cb6753347356e0f8fb7945d371e4993866c3d700bea5f3bbf06f7fa271b330359b1c7602cdacbe09119e01115187635b29d46a3319dc4
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # JsonApiModel
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/json_api_model`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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: Write usage instructions here
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
 
@@ -4,7 +4,7 @@ module JsonApiModel
4
4
  @set = client_result_set
5
5
  end
6
6
 
7
- def as_json
7
+ def as_json( opts = {} )
8
8
  if block_given?
9
9
  yield @set, meta
10
10
  else
@@ -1,3 +1,3 @@
1
1
  module JsonApiModel
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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.0
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-10 00:00:00.000000000 Z
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