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: d0fa65ef7eb8fc9f424b8995c47aaeec25cbff91
4
- data.tar.gz: a7d9cd5bb1aec8857c5e93b69a990ad309e10a0a
3
+ metadata.gz: 2135a3c4a581123c60cddd695143272d269214a3
4
+ data.tar.gz: 19fdc6f5d95b0a2ecc601edd12020a533c7b21e4
5
5
  SHA512:
6
- metadata.gz: b521e76e756b291fa352c617c72ff51ac3073c8fad20ad9c88fe41137c9377bc793f132ab817ed57282b0d789c6fa87f20827885c4fc041ac7eec750ba1df9b3
7
- data.tar.gz: 0d3bedc34f1419b4c338041ef7a962fea86a85c56ce63262224313d8ecb6aa32b9b665a108fa0b40be0c457915be7d98c3dafd86ec140e9a2f4e0602057aae2c
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 = defined?(__decorators) ? __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
- define_method(:__associations) { associations }
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
@@ -1,3 +1,3 @@
1
1
  module ComposableDecorator
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composable_decorator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Steel