pragmatic_serializer 0.4.0 → 0.4.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 +22 -0
- data/lib/pragmatic_serializer/pagination_json.rb +3 -1
- data/lib/pragmatic_serializer/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1305be660f3ab487df094f12a1cfa59c83e5600d
|
4
|
+
data.tar.gz: 20b92366f827032fc42f874e8d6c79d2e4950159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2962de69267aa73a2fdb8665e6a3ea7057ebec78f1baab0dffd9ea09ddbcd76a2d902e7136913a4879df055ddc3ddf8f41a9d7bbcf7ab2a0f7a8c4b78289c37
|
7
|
+
data.tar.gz: b5af38c6be3a88735e39a02b6c38fbc03cc4d77b0226d72f035ea30f184287c0e3f2f913979ec1f13c8ee162a4aef3b273cc9d0f9758651cb84db357a2147298
|
data/README.md
CHANGED
@@ -85,6 +85,10 @@ serializer.as_json
|
|
85
85
|
|
86
86
|
serializer = MySerializer.collection([r1, r2])
|
87
87
|
serializer.resource_options.policy = policy
|
88
|
+
serializer.resource_options.some_other_serializer_method(123, foo:
|
89
|
+
'bar') do
|
90
|
+
puts "hello world"
|
91
|
+
end
|
88
92
|
serializer.as_json
|
89
93
|
```
|
90
94
|
|
@@ -133,6 +137,24 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
133
137
|
|
134
138
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/pragmatic_serializer. 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.
|
135
139
|
|
140
|
+
## Examples
|
141
|
+
|
142
|
+
#### paginated list
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
|
146
|
+
paginated_comments = @comments.limit(limit).offset(offset)
|
147
|
+
|
148
|
+
serializer = CommentSerializer.collection(paginated_comments)
|
149
|
+
serializer.limit = limit
|
150
|
+
serializer.offset = offset
|
151
|
+
serializer.total = @comments.size
|
152
|
+
# serializer.resource_options.include_work = true
|
153
|
+
serializer.pagination_evaluator = ->(limit:, offset:) {
|
154
|
+
comments_path(limit: limit, offset: offset)
|
155
|
+
}
|
156
|
+
serializer.as_json
|
157
|
+
```
|
136
158
|
|
137
159
|
## License
|
138
160
|
|
@@ -10,7 +10,7 @@ module PragmaticSerializer
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def as_json
|
13
|
-
{
|
13
|
+
h = {
|
14
14
|
limit: limit,
|
15
15
|
offset: offset,
|
16
16
|
href: href,
|
@@ -18,6 +18,8 @@ module PragmaticSerializer
|
|
18
18
|
next: self.next,
|
19
19
|
prev: prev,
|
20
20
|
}
|
21
|
+
h.merge!(total: total) if total
|
22
|
+
h
|
21
23
|
end
|
22
24
|
|
23
25
|
def first
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pragmatic_serializer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Valent
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|