geckorate 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -3
- data/lib/geckorate.rb +3 -1
- data/lib/geckorate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c9525ead334719800c2e20d6fa7dd5e9cfb36751d169f70396d509bffce66e
|
4
|
+
data.tar.gz: 386875949ff60c44d9d1bbdefe409efa7a1d8082f41d82a600e7b61e79e3a3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 475bc648f66e0aee79441910d02dbbfe3f18b20c2bd8096ee2263a1d6d2483106a2c2fa8931b5f34176e1b53259c83e5793ff876acef1ba352d8e32234b14a71
|
7
|
+
data.tar.gz: bae056abb12d0d0d954b86a5f84777e603467825e020748834ac5e1cec604661883d6327a0524f81b1734142e9e439458166fa5e9ca84a1b041ffb03c387d8e8
|
data/README.md
CHANGED
@@ -71,9 +71,13 @@ end
|
|
71
71
|
|
72
72
|
### For collections
|
73
73
|
|
74
|
-
There's a method `decorate_collection(collection, options = {})` for
|
75
|
-
|
76
|
-
|
74
|
+
- There's a method `decorate_collection(collection, options = {})` for
|
75
|
+
decorating collections
|
76
|
+
- Example: `PostDecorator.decorate_collection(Post.all)` returns an array of
|
77
|
+
decorated Post objects
|
78
|
+
- The `options` hash can hold parameters to control the decoration:
|
79
|
+
* `:class_name`: the name of the decorator class without the `Decorator` part
|
80
|
+
* `:method`: the method to use for decorating the collection
|
77
81
|
|
78
82
|
### With paginated collections
|
79
83
|
|
data/lib/geckorate.rb
CHANGED
@@ -12,8 +12,10 @@ module Geckorate
|
|
12
12
|
full_klass_name = klass.to_s.concat('Decorator')
|
13
13
|
decorator_klass = Class.const_get(full_klass_name)
|
14
14
|
|
15
|
+
decoration_method = options.fetch(:method, :decorate)
|
16
|
+
|
15
17
|
collection.map do |item|
|
16
|
-
decorator_klass.new(item).
|
18
|
+
decorator_klass.new(item).send(decoration_method, options)
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
data/lib/geckorate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geckorate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed Saleh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|