simple-json-api-serializer 0.3.0 → 0.3.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 +16 -1
- data/lib/json_api.rb +5 -0
- data/lib/json_api/version.rb +1 -1
- metadata +2 -3
- data/lib/simple/json/api/serializer.rb +0 -11
- data/lib/simple/json/api/serializer/version.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 636cf40e78aeed265d14f599509d00c8758b1e1f
|
4
|
+
data.tar.gz: 5a0032a58ffa31c720e0612ea32257168e682a78
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b209862422dbcfe07fb35d895cff8e96e55530d3ddda03fb5d5256feead92d07e2932be77baa5d6e869aae6de5436407c1dc694bdf25a99d4aae7b248766b6c
|
7
|
+
data.tar.gz: e4907962aa34d9de5b90d04c3f91e41a1686c22bdb5de55cba63b1e3ef796976e905dbfdc7ea117fbc2dfc34c8799f99720cf4c8d7389f5776389a8cae7fc810
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* An extremely simple JSON Api serializer.
|
4
4
|
* It supports serializing any Ruby object.
|
5
5
|
* It does not target a specific framework.
|
6
|
-
* Does not (yet) support links
|
6
|
+
* Does not (yet) support links.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -56,6 +56,13 @@ Which generates:
|
|
56
56
|
}
|
57
57
|
```
|
58
58
|
|
59
|
+
You can also use the `hashify` function:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
MyObjectSerializer.hashify(my_object)
|
63
|
+
# { :data => { :type => "my-objects", :id => "1" } }
|
64
|
+
```
|
65
|
+
|
59
66
|
#### Configuring the output
|
60
67
|
|
61
68
|
```ruby
|
@@ -143,6 +150,14 @@ you can specify what method should be called to retrieve the foreign key with
|
|
143
150
|
|
144
151
|
You can also specify the type of the related object with: `has_one :author, type: :user`.
|
145
152
|
|
153
|
+
#### Includes
|
154
|
+
|
155
|
+
You can add includes by adding passing an array of objects to the serialize function:
|
156
|
+
|
157
|
+
```ruby
|
158
|
+
comments_json_hash = CommentSerializer.hashify(comments)
|
159
|
+
PostSerializer.serialize(post, include: comments_json_hash)
|
160
|
+
```
|
146
161
|
|
147
162
|
## Development
|
148
163
|
|
data/lib/json_api.rb
ADDED
data/lib/json_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-json-api-serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Schilstra
|
@@ -84,13 +84,12 @@ files:
|
|
84
84
|
- Rakefile
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
|
+
- lib/json_api.rb
|
87
88
|
- lib/json_api/object_serializer.rb
|
88
89
|
- lib/json_api/object_serializer_definition.rb
|
89
90
|
- lib/json_api/relationship_serializer.rb
|
90
91
|
- lib/json_api/utils.rb
|
91
92
|
- lib/json_api/version.rb
|
92
|
-
- lib/simple/json/api/serializer.rb
|
93
|
-
- lib/simple/json/api/serializer/version.rb
|
94
93
|
- simple-json-api-serializer.gemspec
|
95
94
|
homepage: https://github.com/martndemus/simple-json-api-serializer
|
96
95
|
licenses:
|