You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Breaking changes: - Options now are forwarded to all resources' methods - Main "meta" moved from options hash to be the third argument New features: - Added "json_api_meta" resource method - Errors rescuing Refactored code and tests, thanks to @aJIeks, @spscream & @DNNX from https://russiandevs.slack.com ✌️
Copy file name to clipboardExpand all lines: README.md
+27-12Lines changed: 27 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Official JSON API [implementations page](http://jsonapi.org/implementations/#ser
8
8
9
9
I'd like to notice that there already is one gem called [jbuilder-jsonapi](https://github.com/csexton/jbuilder-jsonapi) by [csexton](https://github.com/csexton), but it adds a links helper only. It's not enough for me! :facepunch:
10
10
11
-
As a result, I've created a **very** lightweight & flexible solution - all you need is Jbuilder and this gem. Then you should delete everything within your `*.json.jbuilder` files and replace it with below recommendations (just one line! :flushed:). After you are free to customize parsed attributes and relationships with two tiny methods.
11
+
As a result, I've created a **very** lightweight & flexible solution - all you need is Jbuilder and this gem. Then you should delete everything within your `*.json.jbuilder` files and replace it with below recommendations (just one line! :flushed:). After you are free to customize parsed attributes and relationships with three tiny methods.
12
12
13
13
## Installation
14
14
@@ -31,10 +31,13 @@ Or install it yourself as:
31
31
Replace any content within any `*.json.jbuilder` file with the code below:
Each resource instance, as well as the included one, will be invoked with `json_api_attrs`& `json_api_relations` methods. These methods **MAY** be implemented within each model. `api_format!` method will try to get an object's permitted (**you are free do define authentication logic yourself!**) attributes and relations via those two methods.
49
+
Each resource instance, as well as the included one, will be invoked with `json_api_attrs (options)`, `json_api_relations (options)`& `json_api_meta (options)` methods. These methods **MAY** be implemented within each model. `api_format!` method will try to get an object's permitted attributes (**remember, you are free do define authentication logic yourself!**) and relations and meta information via those three methods.
**Note** that the gem will call methods pulled with`json_api_relations and _attrs`. As for the above example, methods like `:name`, `:description`, `:orders` will be invoked for an Item instance. And yes, relations are fetched properly if an object responds to `orders`.
66
+
**Note** that the gem will call methods pulled via`json_api_relations and _attrs`. As for the above example, methods like `:name`, `:description`, `:real_price`, `:orders` will be invoked for an Item instance. And yes, relations are fetched properly and recursively if the object responds to `orders`.
64
67
65
68
## Development
66
69
@@ -75,5 +78,17 @@ Bug reports and pull requests are welcome on GitHub at [https://github.com/vladf
75
78
## ToDo
76
79
77
80
-[ ] Maybe add `Content-Type: application/vnd.api+json`. This spec is ignored right now :smirk:
78
-
-[ ] Add links tests
81
+
-[ ] Add links tests and improve them. Links now work only within views (where `@context` is present).
79
82
-[ ] Somehow implement `[fields]` parameter
83
+
84
+
## Versions
85
+
86
+
#### 0.0.1 -> 1.0.0
87
+
88
+
**Breaking:**
89
+
-[x] Now any value can be forwarded to resources' methods via last `options` argument.
90
+
-[x] Added third argument `meta`, which is used to show meta information in the context of request
91
+
92
+
**Not breaking:**
93
+
-[x] Added support for `json_api_meta (options)` method.
0 commit comments