panko_serializer 0.7.2 → 0.7.6

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +39 -0
  3. data/.github/workflows/ruby.yml +48 -0
  4. data/.gitignore +2 -1
  5. data/Gemfile +5 -14
  6. data/README.md +7 -7
  7. data/benchmarks/bm_panko_json.rb +5 -1
  8. data/benchmarks/setup.rb +3 -1
  9. data/benchmarks/type_casts/bm_panko.rb +2 -2
  10. data/docs/.DS_Store +0 -0
  11. data/docs/README.md +195 -8
  12. data/docs/core/Footer.js +81 -0
  13. data/docs/{associations.md → docs/associations.md} +7 -3
  14. data/docs/{attributes.md → docs/attributes.md} +8 -4
  15. data/docs/{design-choices.md → docs/design-choices.md} +6 -2
  16. data/docs/{getting-started.md → docs/getting-started.md} +5 -1
  17. data/docs/docs/introduction.md +13 -0
  18. data/docs/{performance.md → docs/performance.md} +11 -7
  19. data/docs/{response-bag.md → docs/response-bag.md} +24 -1
  20. data/docs/i18n/en.json +50 -0
  21. data/docs/package-lock.json +9673 -0
  22. data/docs/package.json +14 -0
  23. data/docs/sidebars.json +15 -0
  24. data/docs/siteConfig.js +80 -0
  25. data/docs/static/.DS_Store +0 -0
  26. data/docs/static/css/custom.css +51 -0
  27. data/docs/static/img/favicon.ico +0 -0
  28. data/docs/static/img/oss_logo.png +0 -0
  29. data/docs/static/img/undraw_code_review.svg +1 -0
  30. data/docs/static/img/undraw_monitor.svg +1 -0
  31. data/docs/static/img/undraw_note_list.svg +1 -0
  32. data/docs/static/img/undraw_online.svg +1 -0
  33. data/docs/static/img/undraw_open_source.svg +1 -0
  34. data/docs/static/img/undraw_operating_system.svg +1 -0
  35. data/docs/static/img/undraw_react.svg +1 -0
  36. data/docs/static/img/undraw_tweetstorm.svg +1 -0
  37. data/docs/static/img/undraw_youtube_tutorial.svg +1 -0
  38. data/docs/static/index.html +14 -0
  39. data/ext/panko_serializer/attributes_writer/active_record.c +58 -16
  40. data/ext/panko_serializer/attributes_writer/attributes_writer.c +8 -7
  41. data/ext/panko_serializer/attributes_writer/common.h +1 -1
  42. data/ext/panko_serializer/attributes_writer/hash.c +2 -4
  43. data/ext/panko_serializer/attributes_writer/plain.c +2 -3
  44. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.c +70 -21
  45. data/ext/panko_serializer/attributes_writer/type_cast/type_cast.h +1 -2
  46. data/ext/panko_serializer/panko_serializer.c +23 -8
  47. data/ext/panko_serializer/serialization_descriptor/association.c +1 -0
  48. data/ext/panko_serializer/serialization_descriptor/attribute.c +1 -0
  49. data/ext/panko_serializer/serialization_descriptor/serialization_descriptor.c +7 -10
  50. data/lib/panko/association.rb +1 -1
  51. data/lib/panko/object_writer.rb +8 -0
  52. data/lib/panko/response.rb +5 -4
  53. data/lib/panko/serializer.rb +4 -2
  54. data/lib/panko/serializer_resolver.rb +28 -15
  55. data/lib/panko/version.rb +1 -1
  56. data/panko_serializer.gemspec +8 -7
  57. metadata +67 -25
  58. data/.travis.yml +0 -37
  59. data/docs/docpress.json +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 113773350335975bb72a426665ddd642c5e17612418bdc7d01ddf21bfeb27f5d
4
- data.tar.gz: 8de6d3fa50c0dbf44ab72b56c613b0ab84c5fe5e2a5dafe1b32fd226dcb1fb25
3
+ metadata.gz: f4d6afa062eeef46ccbd192d068e9d407003acfd98dd60b3e269caff356bb756
4
+ data.tar.gz: 5049cbdef5d0e33e3731fe4a1469a047726c9b25be853d79f692b6eabe0888b5
5
5
  SHA512:
6
- metadata.gz: 6581eb3745efde92f3ad78e36c89f08e312a9f9156e9248446ab071acb9d7b353a3e3fee43ec5bc4d2d950d49de3e5fdb91ddd151b9f270a63342f1baaabd306
7
- data.tar.gz: 6e1a68875a179725664662d02d3c196f9877ca43750c7d2d29328eee63fdb754b931214030aa67778b78a5a88da2b4fafa30fc8247fd84070de5485519e9a5ec
6
+ metadata.gz: ef58e0cd54374934883ac2dd17146e00ddcdc7f2858664cfb57f78e113990ebe2a766e6766c71bd217db842e96024ff51695ef34a16506ab9d50e6f01462b271
7
+ data.tar.gz: d4bb8d589442812bd12a0e2d4c9d477ab3f5280c1eb9f80594eb93ca5e4153bbbbe0aa2ed517f851b247722d1d8c6240d7cb68dd625f067421a149b04988401b
@@ -0,0 +1,39 @@
1
+ # This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: Docs Publishing
5
+
6
+ on:
7
+ push:
8
+ branches: [ master ]
9
+
10
+ jobs:
11
+ build:
12
+
13
+ runs-on: ubuntu-latest
14
+ env:
15
+ working_directory: 'docs/'
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Use Node.js ${{ matrix.node-version }}
20
+ uses: actions/setup-node@v1
21
+ with:
22
+ node-version: '12.x'
23
+
24
+ - name: Install Dependencies
25
+ working-directory: ${{ env.working_directory }}
26
+ run: npm install
27
+
28
+ - name: Install SSH Client 🔑
29
+ uses: webfactory/ssh-agent@v0.4.1
30
+ with:
31
+ ssh-private-key: ${{ secrets.DEPLOY_KEY }}
32
+
33
+ - name: Publish
34
+ working-directory: ${{ env.working_directory }}
35
+ run: |
36
+ git config --global user.email "action@github.com"
37
+ git config --global user.name "GitHub Action"
38
+ GIT_USER=panko-serializer CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages
39
+
@@ -0,0 +1,48 @@
1
+ name: Panko Serializer CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ ruby: ['2.6', '2.7', '3.0']
13
+ rails: ['6.0.0', '6.1.0']
14
+
15
+ steps:
16
+ - uses: actions/checkout@v2
17
+ - name: Set up Ruby ${{ matrix.ruby }}
18
+ uses: actions/setup-ruby@v1
19
+ with:
20
+ ruby-version: ${{ matrix.ruby }}
21
+
22
+ - name: Install deps
23
+ run: |
24
+ sudo apt update -y
25
+ sudo apt install -y libsqlite3-dev
26
+
27
+ - name: Gems Cache
28
+ id: gem-cache
29
+ uses: actions/cache@v1
30
+ with:
31
+ path: vendor/bundle
32
+ key: ${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
33
+ restore-keys: |
34
+ ${{ runner.os }}-${{ matrix.ruby }}-${{ matrix.rails }}-gem
35
+
36
+ - name: Install gems
37
+ env:
38
+ RAILS_VERSION: ${{ matrix.rails }}
39
+ run: |
40
+ gem install bundler
41
+ bundle config set path 'vendor/bundle'
42
+ bundle check || bundle install --jobs 4 --retry 3
43
+
44
+ - name: Compile & test
45
+ env:
46
+ RAILS_VERSION: ${{ matrix.rails }}
47
+ run: |
48
+ bundle exec rake
data/.gitignore CHANGED
@@ -13,5 +13,6 @@
13
13
 
14
14
  # rspec failure tracking
15
15
  .rspec_status
16
- _docpress
17
16
  node_modules
17
+
18
+ /docs/build/
data/Gemfile CHANGED
@@ -3,7 +3,7 @@ source "https://rubygems.org"
3
3
 
4
4
  gemspec
5
5
 
6
- raw_rails_version = ENV.fetch("RAILS_VERSION", "5.2")
6
+ raw_rails_version = ENV.fetch("RAILS_VERSION", "6.1.0")
7
7
  rails_version = "~> #{raw_rails_version}"
8
8
 
9
9
  gem "activesupport", rails_version
@@ -12,21 +12,12 @@ gem "activerecord", rails_version, group: :test
12
12
 
13
13
 
14
14
  group :benchmarks do
15
- if raw_rails_version.include? "4.2"
16
- gem 'sqlite3', '~> 1.3.6'
17
- else
18
- gem "sqlite3", "~> 1.4"
19
- end
20
-
21
- if raw_rails_version.include? "4.2"
22
- gem "pg", "~> 0.15"
23
- else
24
- gem "pg", ">= 0.18", "< 2.0"
25
- end
15
+ gem "sqlite3", "~> 1.4"
16
+ gem "pg", ">= 0.18", "< 2.0"
26
17
 
27
18
  gem "memory_profiler"
28
- gem "ruby-prof"
29
- gem "ruby-prof-flamegraph"
19
+ gem "ruby-prof", platforms: [:mri]
20
+ gem "ruby-prof-flamegraph", platforms: [:mri]
30
21
 
31
22
  gem "benchmark-ips"
32
23
  gem "active_model_serializers"
data/README.md CHANGED
@@ -1,23 +1,23 @@
1
1
  # Panko
2
2
 
3
- [![Build Status](https://api.travis-ci.com/yosiat/panko_serializer.svg?branch=master)](https://travis-ci.com/yosiat/panko_serializer)
3
+ ![Build Status](https://github.com/panko-serializer/panko_serializer/workflows/Panko%20Serializer%20CI/badge.svg?branch=github-actions)
4
4
 
5
5
  Panko is library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
6
6
 
7
- To achieve it's [performance](https://yosiat.github.io/panko_serializer/performance.html):
7
+ To achieve it's [performance](https://panko.dev/docs/performance.html):
8
8
 
9
- * Oj - Panko relies Oj since it's fast and allow to to serialize incrementally using `Oj::StringWriter`
9
+ * Oj - Panko relies Oj since it's fast and allow to serialize incrementally using `Oj::StringWriter`
10
10
  * Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
11
- * Type casting — Panko does type casting by it's self, instead of relying ActiveRecord.
11
+ * Type casting — Panko does type casting by it's self, instead of relying on ActiveRecord.
12
12
 
13
- To dig deeper about the performance choices, read [Design Choices](https://yosiat.github.io/panko_serializer/design-choices.html).
13
+ To dig deeper about the performance choices, read [Design Choices](https://panko.dev/docs/design-choices.html).
14
14
 
15
15
 
16
16
  Support
17
17
  -------
18
18
 
19
- - [Documentation](https://yosiat.github.io/panko_serializer)
20
- - [Getting Started](https://yosiat.github.io/panko_serializer/getting-started.html)
19
+ - [Documentation](https://panko.dev/docs)
20
+ - [Getting Started](https://panko.dev/docs/getting-started.html)
21
21
  - Join our [slack community](https://pankoserializer.herokuapp.com/)
22
22
 
23
23
  License
@@ -12,6 +12,10 @@ class PostFastSerializer < Panko::Serializer
12
12
  attributes :id, :body, :title, :author_id, :created_at
13
13
  end
14
14
 
15
+ class PostFastWithJsonSerializer < Panko::Serializer
16
+ attributes :id, :body, :title, :author_id, :created_at, :data
17
+ end
18
+
15
19
  class PostFastWithMethodCallSerializer < Panko::Serializer
16
20
  attributes :id, :body, :title, :author_id, :method_call
17
21
 
@@ -32,7 +36,6 @@ class AuthorWithHasManyFastSerializer < Panko::Serializer
32
36
  has_many :posts, serializer: PostFastSerializer
33
37
  end
34
38
 
35
-
36
39
  def benchmark(prefix, serializer, options = {})
37
40
  data = Benchmark.data
38
41
  posts = data[:all]
@@ -54,6 +57,7 @@ def benchmark(prefix, serializer, options = {})
54
57
  end
55
58
 
56
59
  benchmark "Simple", PostFastSerializer
60
+ benchmark "SimpleWithJson", PostFastWithJsonSerializer
57
61
  benchmark "HasOne", PostWithHasOneFastSerializer
58
62
  benchmark "SimpleWithMethodCall", PostFastWithMethodCallSerializer
59
63
  benchmark "Except", PostWithHasOneFastSerializer, except: [:title]
data/benchmarks/setup.rb CHANGED
@@ -25,6 +25,7 @@ ActiveRecord::Schema.define do
25
25
  t.text :body
26
26
  t.string :title
27
27
  t.references :author
28
+ t.json :data
28
29
  t.timestamps(null: false)
29
30
  end
30
31
  end
@@ -47,7 +48,8 @@ Post.transaction do
47
48
  Post.create(
48
49
  body: "something about how password restrictions are evil, and less secure, and with the math to prove it.",
49
50
  title: "Your bank is does not know how to do security",
50
- author: Author.create(name: "Preston Sego")
51
+ author: Author.create(name: "Preston Sego"),
52
+ data: { a: 1, b: 2, c: 3 }
51
53
  )
52
54
  end
53
55
  end
@@ -59,10 +59,10 @@ if ENV["RAILS_VERSION"].start_with? "4.2"
59
59
  end
60
60
 
61
61
  if check_if_exists "ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Json"
62
- panko_type_convert ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Json, '{"a":1}', {a:1}
62
+ panko_type_convert ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Json, '{"a":1}', '{"a":1}'
63
63
  end
64
64
  if check_if_exists "ActiveRecord::Type::Json"
65
- panko_type_convert ActiveRecord::Type::Json, '{"a":1}', {a:1}
65
+ panko_type_convert ActiveRecord::Type::Json, '{"a":1}', '{"a":1}'
66
66
  end
67
67
  db_panko_time
68
68
  utc_panko_time
data/docs/.DS_Store ADDED
Binary file
data/docs/README.md CHANGED
@@ -1,11 +1,198 @@
1
- * [Panko](../README.md)
2
- * [Getting Started](getting-started.md)
3
- * Reference
4
- * [Attributes](attributes.md)
5
- * [Associations](associations.md)
6
- * [Response bag](response-bag.md)
7
- * [Performance](performance.md)
8
- * [Design Choices](design-choices.md)
1
+ This website was created with [Docusaurus](https://docusaurus.io/).
9
2
 
3
+ # What's In This Document
10
4
 
5
+ - [Get Started in 5 Minutes](#get-started-in-5-minutes)
6
+ - [Directory Structure](#directory-structure)
7
+ - [Editing Content](#editing-content)
8
+ - [Adding Content](#adding-content)
9
+ - [Full Documentation](#full-documentation)
11
10
 
11
+ # Get Started in 5 Minutes
12
+
13
+ 1. Make sure all the dependencies for the website are installed:
14
+
15
+ ```sh
16
+ # Install dependencies
17
+ $ yarn
18
+ ```
19
+
20
+ 2. Run your dev server:
21
+
22
+ ```sh
23
+ # Start the site
24
+ $ yarn start
25
+ ```
26
+
27
+ ## Directory Structure
28
+
29
+ Your project file structure should look something like this
30
+
31
+ ```
32
+ my-docusaurus/
33
+ docs/
34
+ doc-1.md
35
+ doc-2.md
36
+ doc-3.md
37
+ website/
38
+ blog/
39
+ 2016-3-11-oldest-post.md
40
+ 2017-10-24-newest-post.md
41
+ core/
42
+ node_modules/
43
+ pages/
44
+ static/
45
+ css/
46
+ img/
47
+ package.json
48
+ sidebars.json
49
+ siteConfig.js
50
+ ```
51
+
52
+ # Editing Content
53
+
54
+ ## Editing an existing docs page
55
+
56
+ Edit docs by navigating to `docs/` and editing the corresponding document:
57
+
58
+ `docs/doc-to-be-edited.md`
59
+
60
+ ```markdown
61
+ ---
62
+ id: page-needs-edit
63
+ title: This Doc Needs To Be Edited
64
+ ---
65
+
66
+ Edit me...
67
+ ```
68
+
69
+ For more information about docs, click [here](https://docusaurus.io/docs/en/navigation)
70
+
71
+ ## Editing an existing blog post
72
+
73
+ Edit blog posts by navigating to `website/blog` and editing the corresponding post:
74
+
75
+ `website/blog/post-to-be-edited.md`
76
+
77
+ ```markdown
78
+ ---
79
+ id: post-needs-edit
80
+ title: This Blog Post Needs To Be Edited
81
+ ---
82
+
83
+ Edit me...
84
+ ```
85
+
86
+ For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog)
87
+
88
+ # Adding Content
89
+
90
+ ## Adding a new docs page to an existing sidebar
91
+
92
+ 1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`:
93
+
94
+ ```md
95
+ ---
96
+ id: newly-created-doc
97
+ title: This Doc Needs To Be Edited
98
+ ---
99
+
100
+ My new content here..
101
+ ```
102
+
103
+ 1. Refer to that doc's ID in an existing sidebar in `website/sidebars.json`:
104
+
105
+ ```javascript
106
+ // Add newly-created-doc to the Getting Started category of docs
107
+ {
108
+ "docs": {
109
+ "Getting Started": [
110
+ "quick-start",
111
+ "newly-created-doc" // new doc here
112
+ ],
113
+ ...
114
+ },
115
+ ...
116
+ }
117
+ ```
118
+
119
+ For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation)
120
+
121
+ ## Adding a new blog post
122
+
123
+ 1. Make sure there is a header link to your blog in `website/siteConfig.js`:
124
+
125
+ `website/siteConfig.js`
126
+
127
+ ```javascript
128
+ headerLinks: [
129
+ ...
130
+ { blog: true, label: 'Blog' },
131
+ ...
132
+ ]
133
+ ```
134
+
135
+ 2. Create the blog post with the format `YYYY-MM-DD-My-Blog-Post-Title.md` in `website/blog`:
136
+
137
+ `website/blog/2018-05-21-New-Blog-Post.md`
138
+
139
+ ```markdown
140
+ ---
141
+ author: Frank Li
142
+ authorURL: https://twitter.com/foobarbaz
143
+ authorFBID: 503283835
144
+ title: New Blog Post
145
+ ---
146
+
147
+ Lorem Ipsum...
148
+ ```
149
+
150
+ For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog)
151
+
152
+ ## Adding items to your site's top navigation bar
153
+
154
+ 1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`:
155
+
156
+ `website/siteConfig.js`
157
+
158
+ ```javascript
159
+ {
160
+ headerLinks: [
161
+ ...
162
+ /* you can add docs */
163
+ { doc: 'my-examples', label: 'Examples' },
164
+ /* you can add custom pages */
165
+ { page: 'help', label: 'Help' },
166
+ /* you can add external links */
167
+ { href: 'https://github.com/facebook/docusaurus', label: 'GitHub' },
168
+ ...
169
+ ],
170
+ ...
171
+ }
172
+ ```
173
+
174
+ For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation)
175
+
176
+ ## Adding custom pages
177
+
178
+ 1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`:
179
+ 1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element:
180
+
181
+ `website/siteConfig.js`
182
+
183
+ ```javascript
184
+ {
185
+ headerLinks: [
186
+ ...
187
+ { page: 'my-new-custom-page', label: 'My New Custom Page' },
188
+ ...
189
+ ],
190
+ ...
191
+ }
192
+ ```
193
+
194
+ For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages).
195
+
196
+ # Full Documentation
197
+
198
+ Full documentation can be found on the [website](https://docusaurus.io/).
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Copyright (c) 2017-present, Facebook, Inc.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ const React = require('react');
9
+
10
+ class Footer extends React.Component {
11
+ docUrl(doc, language) {
12
+ const baseUrl = this.props.config.baseUrl;
13
+ const docsUrl = this.props.config.docsUrl;
14
+ const docsPart = `${docsUrl ? `${docsUrl}/` : ''}`;
15
+ return `${baseUrl}${docsPart}${doc}`;
16
+ }
17
+
18
+ pageUrl(doc, language) {
19
+ const baseUrl = this.props.config.baseUrl;
20
+ return baseUrl + (language ? `${language}/` : '') + doc;
21
+ }
22
+
23
+ render() {
24
+ return (
25
+ <footer className="nav-footer" id="footer">
26
+ <section className="sitemap">
27
+ <a href={this.props.config.baseUrl} className="nav-home">
28
+ {this.props.config.footerIcon && (
29
+ <img
30
+ src={this.props.config.baseUrl + this.props.config.footerIcon}
31
+ alt={this.props.config.title}
32
+ width="66"
33
+ height="58"
34
+ />
35
+ )}
36
+ </a>
37
+ <div>
38
+ <h5>Docs</h5>
39
+ <a href={this.docUrl('getting-started.html', this.props.language)}>
40
+ Getting Started
41
+ </a>
42
+ <a href={this.docUrl('attributes.html', this.props.language)}>
43
+ Guides
44
+ </a>
45
+ <a href={this.docUrl('performance.html', this.props.language)}>
46
+ Performance
47
+ </a>
48
+ </div>
49
+ <div>
50
+ <h5>More</h5>
51
+ <a href="https://github.com/panko-serializer/panko_serializer">GitHub</a>
52
+ <a href="https://pankoserializer.herokuapp.com/">Slack</a>
53
+ <a
54
+ className="github-button"
55
+ href={this.props.config.repoUrl}
56
+ data-icon="octicon-star"
57
+ data-count-href="/panko-serializer/panko_serializer/stargazers"
58
+ data-show-count="true"
59
+ data-count-aria-label="# stargazers on GitHub"
60
+ aria-label="Star this project on GitHub">
61
+ Star
62
+ </a>
63
+ {this.props.config.twitterUsername && (
64
+ <div className="social">
65
+ <a
66
+ href={`https://twitter.com/${this.props.config.twitterUsername}`}
67
+ className="twitter-follow-button">
68
+ Follow @{this.props.config.twitterUsername}
69
+ </a>
70
+ </div>
71
+ )}
72
+ </div>
73
+ </section>
74
+
75
+ <section className="copyright">{this.props.config.copyright}</section>
76
+ </footer>
77
+ );
78
+ }
79
+ }
80
+
81
+ module.exports = Footer;
@@ -1,4 +1,8 @@
1
- # Associations
1
+ ---
2
+ id: associations
3
+ title: Associations
4
+ sidebar_label: Associations
5
+ ---
2
6
 
3
7
  A serializer can define it's own associations - both `has_many` and `has_one` to serializer under the context of the object.
4
8
 
@@ -66,7 +70,7 @@ Panko::ArraySerializer.new(posts, only: {
66
70
  })
67
71
  ```
68
72
 
69
- Let's disect `only` option we passed -
73
+ Let's dissect `only` option we passed -
70
74
  * `instance` - list of attributes (and associations) we want to serializer for current instance of the serializer, in this case - `PostSerializer`.
71
75
  * `author`, `comments` - here we specify the list of attributes we want to serialize for each association.
72
76
 
@@ -87,4 +91,4 @@ Panko::ArraySerializer.new(posts, only: {
87
91
  })
88
92
  ```
89
93
 
90
- As you see now in `comments` the `instance` have differenet meaning, the `CommentSerializer`.
94
+ As you see now in `comments` the `instance` have different meaning, the `CommentSerializer`.
@@ -1,4 +1,8 @@
1
- # Attributes
1
+ ---
2
+ id: attributes
3
+ title: Attributes
4
+ sidebar_label: Attributes
5
+ ---
2
6
 
3
7
  Attributes allow you to specify which record attributes you want to serialize,
4
8
  There are two types of attributes:
@@ -42,7 +46,7 @@ end
42
46
 
43
47
  Another useful, thing you can pass your serializer is `context`, a `context` is a bag of data whom your serializer may need.
44
48
 
45
- For example, here we will pass the current user:
49
+ For example, here we will pass feature flags:
46
50
  ```ruby
47
51
  class UserSerializer < Panko::Serializer
48
52
  attributes :id, :email
@@ -84,7 +88,7 @@ UserSerializer.new(except: [:name]).serialize(User.first)
84
88
  > property is not taken into account.
85
89
  > If you have a `has_many :state_transitions, name: :history` association
86
90
  > defined, the key to use in filters is `:state_transitions`
87
- > (e.g. `{ except: [:state_statitions] }`)
91
+ > (e.g. `{ except: [:state_transitions] }`)
88
92
 
89
93
  ## Filters For
90
94
 
@@ -106,7 +110,7 @@ end
106
110
  UserSerializer.serialize(User.first)
107
111
  ```
108
112
 
109
- > See disucssion in: https://github.com/yosiat/panko_serializer/issues/16
113
+ > See discussion in: https://github.com/panko-serializer/panko_serializer/issues/16
110
114
 
111
115
  ## Aliases
112
116
 
@@ -1,4 +1,8 @@
1
- # Design Choices
1
+ ---
2
+ id: design-choices
3
+ title: Design Choices
4
+ sidebar_label: Design Choices
5
+ ---
2
6
 
3
7
  In short, Panko, is a serializer for ActiveRecord objects (it can't serialize any other object), which strives for high performance & simple API (which is inspired by ActiveModelSerializers).
4
8
 
@@ -33,7 +37,7 @@ And the usage of this serializer will be:
33
37
  user = User.first
34
38
 
35
39
  # create serializer, with empty options
36
- serializer = UserSerilizer.new
40
+ serializer = UserSerializer.new
37
41
 
38
42
  # serialize to JSON
39
43
  serializer.serialize_to_json(user)
@@ -1,4 +1,8 @@
1
- # Getting Started
1
+ ---
2
+ id: getting-started
3
+ title: Getting Started
4
+ sidebar_label: Getting Started
5
+ ---
2
6
 
3
7
  ## Installation
4
8
 
@@ -0,0 +1,13 @@
1
+ ---
2
+ id: index
3
+ title: Introduction
4
+ sidebar_label: Introduction
5
+ ---
6
+
7
+ Panko is library which is inspired by ActiveModelSerializers 0.9 for serializing ActiveRecord/Ruby objects to JSON strings, fast.
8
+
9
+ To achieve it's [performance](https://panko.dev/docs/performance.html):
10
+
11
+ * Oj - Panko relies Oj since it's fast and allow to to serialize incrementally using `Oj::StringWriter`
12
+ * Serialization Descriptor - Panko computes most of the metadata ahead of time, to save time later in serialization.
13
+ * Type casting — Panko does type casting by it's self, instead of relying ActiveRecord.
@@ -1,18 +1,22 @@
1
- # Performance
1
+ ---
2
+ id: performance
3
+ title: Performance
4
+ sidebar_label: Performance
5
+ ---
2
6
 
3
7
  The performance of Panko is measured using microbenchmarks and load testing.
4
8
 
5
9
  ## Microbenchmarks
6
10
 
7
- The following microbenchmarks are run on MacBook Pro (Retina, 15-inch, 2017), Ruby 2.5.1 with Rails 5.2.1
8
- demonstrating the performance of ActiveModelSerializers 0.10.7 and Panko 0.5.6
11
+ The following microbenchmarks are run on MacBook Pro (15-inch, 2018), Ruby 2.6.3 with Rails 6.0.2.1
12
+ demonstrating the performance of ActiveModelSerializers 0.10.10 and Panko 0.7.2
9
13
 
10
14
  | Benchmark | AMS ip/s | Panko ip/s |
11
15
  | ----------------- | -------- | ---------- |
12
- | Simple_Posts_2300 | 9.47 | 185.9 |
13
- | Simple_Posts_50 | 450.49 | 9,237.66 |
14
- | HasOne_Posts_2300 | 4.27 | 104.39 |
15
- | HasOne_Posts_50 | 219.67 | 4,901.09 |
16
+ | Simple_Posts_2300 | 5.4 | 190.48 |
17
+ | Simple_Posts_50 | 261.28 | 9,347.4 |
18
+ | HasOne_Posts_2300 | 2.54 | 90.71 |
19
+ | HasOne_Posts_50 | 124.29 | 5,421.55 |
16
20
 
17
21
  ## Real-world benchmark
18
22