pg_serializable 1.0.0 → 1.0.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 +4 -4
- data/README.md +27 -7
- data/lib/pg_serializable/version.rb +1 -1
- data/lib/pg_serializable.rb +2 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ad9aa2e86537b9e90363067625b34571a0ddb0f
|
4
|
+
data.tar.gz: 45100cfb29c1b503e401d5d56ef17a9bb39c10b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cecc2cd7e183a54ad507420bfbc9806a12fafe325276d1bcb3b0696ad436c1f70405428bb988538aa01c9f148fc8ee7782947fe1fb90258d56145b9d43916052
|
7
|
+
data.tar.gz: 8c9ad3b2547e69f8548f9faa1807ea00bebcb1a5b981903fbf263c05661ca2718fd9a0d6997687afa169fb62e827d89aee9951b63f4b0c815d26278bc62b5b1d
|
data/README.md
CHANGED
@@ -44,6 +44,21 @@ end
|
|
44
44
|
Completed 200 OK in 2521ms (Views: 2431.8ms | ActiveRecord: 45.7ms)
|
45
45
|
```
|
46
46
|
|
47
|
+
Using fast_jsonapi:
|
48
|
+
```ruby
|
49
|
+
class Api::ProductsController < ApplicationController
|
50
|
+
def index
|
51
|
+
@products = Product.limit(200)
|
52
|
+
.order(updated_at: :desc)
|
53
|
+
.includes(:categories, :label, variations: :color)
|
54
|
+
render json: ProductSerializer.new(@products).serialized_json
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
58
|
+
```shell
|
59
|
+
Completed 200 OK in 315ms (Views: 0.2ms | ActiveRecord: 50.3ms)
|
60
|
+
```
|
61
|
+
|
47
62
|
Using PgSerializable:
|
48
63
|
```ruby
|
49
64
|
class Api::ProductsController < ApplicationController
|
@@ -53,9 +68,18 @@ class Api::ProductsController < ApplicationController
|
|
53
68
|
end
|
54
69
|
```
|
55
70
|
```shell
|
56
|
-
Completed 200 OK in
|
71
|
+
Completed 200 OK in 109ms (Views: 0.2ms | ActiveRecord: 87.1ms)
|
57
72
|
```
|
58
73
|
|
74
|
+
Benchmarking `fast_jsonapi` against `pg_serializable` on 100 requests:
|
75
|
+
```shell
|
76
|
+
user system total real
|
77
|
+
fast_jsonapi 21.510000 0.700000 22.210000 ( 26.994325)
|
78
|
+
pg_serializable 1.470000 0.170000 1.640000 ( 9.187275)
|
79
|
+
```
|
80
|
+
|
81
|
+
You'll see the greatest benefits from PgSerializable for deeply nested json objects.
|
82
|
+
|
59
83
|
## Installation
|
60
84
|
|
61
85
|
Add this line to your application's Gemfile:
|
@@ -475,14 +499,10 @@ render json: Product.limit(3).json(trait: :with_variations)
|
|
475
499
|
|
476
500
|
TODO
|
477
501
|
|
478
|
-
## Contributing
|
479
|
-
|
480
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/matthewjf/pg_serializable. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
481
|
-
|
482
502
|
## License
|
483
503
|
|
484
504
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
485
505
|
|
486
|
-
##
|
506
|
+
## Acknowledgements
|
487
507
|
|
488
|
-
|
508
|
+
Full credit Colin Rhodes for the idea.
|
data/lib/pg_serializable.rb
CHANGED