pragmatic_serializer 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 358009ad79164256e989d1023de3df4159ab890a
4
- data.tar.gz: 717e862876a3fec0f6f11a39db296a4b332442e8
3
+ metadata.gz: 1305be660f3ab487df094f12a1cfa59c83e5600d
4
+ data.tar.gz: 20b92366f827032fc42f874e8d6c79d2e4950159
5
5
  SHA512:
6
- metadata.gz: 8ed3f9b3c44da8ce808f0e78e5c0fa7406b13c77970f27a0513669b9c7ce143259d3626bb31fe04b213669e325aa56d587ace5caa053c7ef2cec12eeff644bf3
7
- data.tar.gz: 87c8b2b71017d6edef53f3903b64728c56a18cbe93f91a409f843d58affd18e5e7ff27d44fa82038508d9b1d626203ba368fc02e1ba25298f5f2f36efbe5c203
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
@@ -1,3 +1,3 @@
1
1
  module PragmaticSerializer
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
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.0
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-01 00:00:00.000000000 Z
11
+ date: 2018-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport