geckorate 0.1.2 → 0.2.0
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/lib/geckorate/version.rb +1 -1
- data/lib/geckorate.rb +7 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35f3de94b8e35723fafca3d753d3cb73de5780ae856c65ac01b78745969fc4fa
|
4
|
+
data.tar.gz: fff006750bb1239bc7ee0aea196a96c97a3272e734cfc175c0384982df05ab13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5e2e5e8cdc9e99cb13046e9df6b584b2aac89a554949b2f307afff9d90882bc5dd8638d8df653eff74f39043733cc11f26d3affc6c8501bbaebbee62b6c20ff
|
7
|
+
data.tar.gz: 724aa2b1b508faf47f088e81018031de246276de52c5f0989de3426b3547d4de623a03307464e8f7990f0ffcc8ba92a9e2661ee0dddbc3bfd26a32a28b976dc0
|
data/lib/geckorate/version.rb
CHANGED
data/lib/geckorate.rb
CHANGED
@@ -2,10 +2,10 @@ require "geckorate/version"
|
|
2
2
|
|
3
3
|
module Geckorate
|
4
4
|
class Decorator < SimpleDelegator
|
5
|
-
def decorate; end
|
5
|
+
def decorate(options = {}); end
|
6
6
|
|
7
7
|
class << self
|
8
|
-
def decorate_collection(collection, class_name
|
8
|
+
def decorate_collection(collection, class_name: nil, options: {})
|
9
9
|
return [] if collection.empty?
|
10
10
|
|
11
11
|
klass = class_name || collection.first.class
|
@@ -13,25 +13,25 @@ module Geckorate
|
|
13
13
|
decorator_klass = Class.const_get(full_klass_name)
|
14
14
|
|
15
15
|
collection.map do |item|
|
16
|
-
decorator_klass.new(item).decorate
|
16
|
+
decorator_klass.new(item).decorate(options: options)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
def decorate_kaminari_collection(collection, class_name
|
20
|
+
def decorate_kaminari_collection(collection, class_name: nil, options: {})
|
21
21
|
{
|
22
22
|
page: collection.current_page,
|
23
23
|
per_page: collection.current_per_page,
|
24
24
|
total: collection.total_count,
|
25
|
-
records: decorate_collection(collection, class_name)
|
25
|
+
records: decorate_collection(collection, class_name: class_name, options: options)
|
26
26
|
}
|
27
27
|
end
|
28
28
|
|
29
|
-
def decorate_will_paginate_collection(collection, class_name
|
29
|
+
def decorate_will_paginate_collection(collection, class_name: nil, options: {})
|
30
30
|
{
|
31
31
|
page: collection.current_page,
|
32
32
|
per_page: collection.per_page,
|
33
33
|
total: collection.total_entries,
|
34
|
-
records: decorate_collection(collection, class_name)
|
34
|
+
records: decorate_collection(collection, class_name: class_name, options: options)
|
35
35
|
}
|
36
36
|
end
|
37
37
|
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.
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2019-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,8 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.7.6
|
93
|
+
rubygems_version: 3.0.3
|
95
94
|
signing_key:
|
96
95
|
specification_version: 4
|
97
96
|
summary: A dead simple decorator for Ruby
|