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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae64051898a555265e590a35db8dd7772269f7d03b1305dda594bcd3fbe1c31e
4
- data.tar.gz: 211bdf9f83780632ff92c01f3a46e96c64b0606c3abcc43ce0bd41105d3e3960
3
+ metadata.gz: 30c9525ead334719800c2e20d6fa7dd5e9cfb36751d169f70396d509bffce66e
4
+ data.tar.gz: 386875949ff60c44d9d1bbdefe409efa7a1d8082f41d82a600e7b61e79e3a3db
5
5
  SHA512:
6
- metadata.gz: d132d63d8176d5940a9a022634b0f663a0dbf730b4f0d89e0eb5b696870fae5364633f759300d91eeda96c8d4ccb644d9d438f93c156037050e04fc03e90ba47
7
- data.tar.gz: 02f6595dcf68fa25ff1e8f3478373802a5160fade930d755d08ecaf99c2866e422f912957bc4a32720990d612fef8ed91ae9880566b881195bc2e4d059bb3bc1
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 decorating collections.
75
- Example: `PostDecorator.decorate_collection(Post.all)` returns an array of
76
- decorated Post objects.
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
 
@@ -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).decorate(options)
18
+ decorator_klass.new(item).send(decoration_method, options)
17
19
  end
18
20
  end
19
21
 
@@ -1,3 +1,3 @@
1
1
  module Geckorate
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.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-04-29 00:00:00.000000000 Z
11
+ date: 2019-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler