simple-json-api-serializer 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ba77670aea7fe65f45dd044dd16de898d538b57
4
- data.tar.gz: 6b3e6626f0a06154cfe61d992f63cd932593860f
3
+ metadata.gz: 636cf40e78aeed265d14f599509d00c8758b1e1f
4
+ data.tar.gz: 5a0032a58ffa31c720e0612ea32257168e682a78
5
5
  SHA512:
6
- metadata.gz: 203f943f6ba18beb7b1a79a27b4507251f811aeca62bf2b1bc03fa1f30ead13ace20544ee051d502f7f6712649fb293b7b2d3e1235cd8c10da933270aad813a4
7
- data.tar.gz: 9f8f084339a487a9c3cfb3a64861b333461d21c31386017700e796b1854599db992a4f2c8f1f7e1a9eb57cfeef05ba1dba74e66a879dff34a73a17f0987a1265
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 and includes.
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
@@ -0,0 +1,5 @@
1
+ module JSONApi
2
+ require 'json_api/utils'
3
+ require 'json_api/object_serializer'
4
+ require 'json_api/object_serializer_definition'
5
+ end
@@ -1,3 +1,3 @@
1
1
  module JSONApi
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
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.0
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:
@@ -1,11 +0,0 @@
1
- require "simple/json/api/serializer/version"
2
-
3
- module Simple
4
- module Json
5
- module Api
6
- module Serializer
7
- # Your code goes here...
8
- end
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- module Simple
2
- module Json
3
- module Api
4
- module Serializer
5
- VERSION = "0.1.0"
6
- end
7
- end
8
- end
9
- end