decoru 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -2
- data/lib/decoru/decoratable.rb +4 -0
- data/lib/decoru/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: 516b0a428cf401d2b92e35ec2863ce4b92e930ce70870c913e36dd89352f34ed
|
4
|
+
data.tar.gz: e2ac724b3da0a21e14a9f1ad2b30b42ec651d3ccc81fb2cc54f6afd36a1d8895
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fac95dd91122f8c45ef3d26055f74547d80961809e8fc020588e2b84052b543e43f8fc9210190e283bc9f2433040c0bc1e15fef60661178b2b16f395e316866
|
7
|
+
data.tar.gz: 550986195dcf4a9609366d4a08db40d6c9feaa1ff8a94abfd86c5ee175060543023533432933d8f898765d6fec114358f37977f19f6a014d542541e9d86c0ab0
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -7,11 +7,15 @@ A simple decorator for Rails models.
|
|
7
7
|
```ruby
|
8
8
|
# app/controllers/users_controller.rb
|
9
9
|
def show
|
10
|
-
@user = User.find(params[:id]).
|
10
|
+
@user = User.find(params[:id]).decoru
|
11
|
+
# or
|
12
|
+
# @user = User.find(params[:id]).decorate
|
11
13
|
end
|
12
14
|
|
13
15
|
def index
|
14
|
-
@users = User.first(10).
|
16
|
+
@users = User.first(10).decoru
|
17
|
+
# or
|
18
|
+
# @users = User.first(10).decorate
|
15
19
|
end
|
16
20
|
```
|
17
21
|
|
data/lib/decoru/decoratable.rb
CHANGED
@@ -8,6 +8,8 @@ module Decoru
|
|
8
8
|
all.map(&:decorate)
|
9
9
|
end
|
10
10
|
|
11
|
+
alias_method :decoru, :decorate
|
12
|
+
|
11
13
|
# Infers the decorator class to be used by (e.g. `User` maps to `UserDecorator`).
|
12
14
|
# adapted from https://github.com/drapergem/draper/blob/157eb955072a941e6455e0121fca09a989fcbc21/lib/draper/decoratable.rb#L71
|
13
15
|
def decorator_class(called_on = self)
|
@@ -27,6 +29,8 @@ module Decoru
|
|
27
29
|
self.class.decorator_class.new(self)
|
28
30
|
end
|
29
31
|
|
32
|
+
alias_method :decoru, :decorate
|
33
|
+
|
30
34
|
def decorated?
|
31
35
|
false
|
32
36
|
end
|
data/lib/decoru/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decoru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- aki77
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|