wor-paginate 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/README.md +14 -0
- data/lib/wor/paginate/formatter.rb +1 -1
- data/lib/wor/paginate/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b525d480a4cfe283c91c14c2a8e2ce570b65ded15e2678d76f1e9c0f35143a24
|
4
|
+
data.tar.gz: 585dfb16534cc0daafe39dbe52d238a8f1142f80bc65085c95acc9f2e506e9d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da4b6ae0100e232077386f260c4465412d8cf010240a24011cd68308176f1c7082bbef1890c6f893c10a831d3ec56b8d2e005d33ec877d3f1d299d4888e4b053
|
7
|
+
data.tar.gz: 83e2ded8da3f41efb31765ed6ef29c076ec659e227c4aab579bf02a490f4c4afc6343a8a45fe3e456767195490fcd52f819a1b1e5f59bad85bb35e83693f4622
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
## Change log
|
2
2
|
|
3
|
+
### V0.1.6
|
4
|
+
* [#62](https://github.com/Wolox/wor-paginate/pull/62): Add options in active model serializer - [@blacksam07](https://github.com/blacksam07).
|
3
5
|
|
4
6
|
### V0.1.5
|
5
7
|
* [#59](https://github.com/Wolox/wor-paginate/pull/59): Add include option to serialize nested models - [@jcgrethe](https://github.com/jcgrethe).
|
data/README.md
CHANGED
@@ -104,6 +104,20 @@ render_paginated DummyModel, each_serializer: CustomDummyModelSerializer
|
|
104
104
|
```
|
105
105
|
where the serializer is just an [`ActiveModel::Serializer`](https://github.com/rails-api/active_model_serializers).
|
106
106
|
|
107
|
+
#### Custom options
|
108
|
+
Using custom options in serializer, example method `current_user`
|
109
|
+
```ruby
|
110
|
+
render_paginated DummyModel, each_serializer: CustomDummyModelSerializer, current_user: current_user
|
111
|
+
```
|
112
|
+
In serializer
|
113
|
+
```ruby
|
114
|
+
class CustomSerializer < ActiveModel::Serializer
|
115
|
+
def method
|
116
|
+
@instance_options[:current_user]
|
117
|
+
end
|
118
|
+
end
|
119
|
+
```
|
120
|
+
|
107
121
|
#### Custom formatters
|
108
122
|
A formatter is an object that defines the output of the render_paginated method. In case the application needs a different format for a request, it can be passed to the `render_paginated` method using the `formatter` option:
|
109
123
|
```ruby
|
@@ -33,7 +33,7 @@ module Wor
|
|
33
33
|
|
34
34
|
def serialized_content
|
35
35
|
if serializer.present?
|
36
|
-
return paginated_content.map { |item| serializer.new(item,
|
36
|
+
return paginated_content.map { |item| serializer.new(item, options) }
|
37
37
|
end
|
38
38
|
if defined? ActiveModelSerializers::SerializableResource
|
39
39
|
ActiveModelSerializers::SerializableResource.new(paginated_content).as_json
|
data/lib/wor/paginate/version.rb
CHANGED