composable_decorator 0.2.1 → 0.2.2
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2135a3c4a581123c60cddd695143272d269214a3
|
4
|
+
data.tar.gz: 19fdc6f5d95b0a2ecc601edd12020a533c7b21e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3964c582e98ba1a5b2a233369580c2f0102b3b12f7d7cbd4afa57bfc5f087bd94b9ecd3bc374fe1cb9aeaa907154949d01486b7593a1591551d62430e4c1d981
|
7
|
+
data.tar.gz: 70e9f2e657000046f24523c3ff68fc93bd4bc6ab4fad230159628a68152ef2bcd452eaab2ddad5cc06d6d5f8d5af1f0f51c8c0698f88150f39de9508234d0b9e
|
@@ -7,6 +7,7 @@ module ComposableDecorator
|
|
7
7
|
mod.extend DSL
|
8
8
|
|
9
9
|
mod.__define_delegation
|
10
|
+
mod.__initialize_decorators
|
10
11
|
end
|
11
12
|
|
12
13
|
def decorate
|
@@ -45,6 +46,10 @@ module ComposableDecorator
|
|
45
46
|
self.class.__decorators
|
46
47
|
end
|
47
48
|
|
49
|
+
private def __associations
|
50
|
+
self.class.__associations
|
51
|
+
end
|
52
|
+
|
48
53
|
private def __decorator_methods(assoc)
|
49
54
|
__association_class(assoc).__decorators.map(&:instance_methods).flatten
|
50
55
|
end
|
@@ -12,11 +12,15 @@ module ComposableDecorator
|
|
12
12
|
#
|
13
13
|
# @Param +decorators+ is an <Array> of classes
|
14
14
|
def decorate_with(*decorators)
|
15
|
-
existing_decorators =
|
15
|
+
existing_decorators = __decorators
|
16
16
|
|
17
17
|
define_singleton_method(:__decorators) { decorators + existing_decorators }
|
18
18
|
end
|
19
19
|
|
20
|
+
def __initialize_decorators
|
21
|
+
define_singleton_method(:__decorators) { [] }
|
22
|
+
end
|
23
|
+
|
20
24
|
# # delegates all of the decorated methods for each has_one or belongs_to association.
|
21
25
|
#
|
22
26
|
# module PostDecorator
|
@@ -39,18 +43,19 @@ module ComposableDecorator
|
|
39
43
|
#
|
40
44
|
# @Param +associations+ is an <Array> of symbols
|
41
45
|
def delegate_decorated_to(*associations, prefix: true, allow_nil: true, handle_nil_with: '')
|
46
|
+
existing_associations = __associations
|
47
|
+
|
42
48
|
__define_delegation(
|
43
|
-
associations: associations,
|
49
|
+
associations: associations + existing_associations,
|
44
50
|
prefix: prefix,
|
45
51
|
allow_nil: allow_nil,
|
46
52
|
handle_nil_with: handle_nil_with)
|
47
53
|
end
|
48
54
|
|
49
55
|
def __define_delegation(associations: [], prefix: true, allow_nil: true, handle_nil_with: '')
|
50
|
-
|
56
|
+
define_singleton_method(:__associations) { associations }
|
51
57
|
define_method(:__prefix) { prefix }
|
52
58
|
define_method(:__allow_nil) { allow_nil }
|
53
|
-
define_method(:__handle_nil_with) { handle_nil_with }
|
54
59
|
end
|
55
60
|
end
|
56
61
|
end
|