compo 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 +5 -0
- data/README.md +9 -1
- data/lib/compo/composite.rb +5 -5
- data/lib/compo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 914e22d4c5fb780ddfb95a6b71ecabf0046200b1
|
4
|
+
data.tar.gz: 91fa7096c61860f8aa06b7d773a3c8a490ac1cb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6477ff141c788b2889b06c7674bb0ffcb157880f739e7ab0532a866e917fe4df56c19dffb8794b69caaffb1f011ff463326435460334a95c58813cdea3d2c4c
|
7
|
+
data.tar.gz: 42527748f975f4e21bfbf8ca7b3b8cc46cda5304eaf586bd5ea37961c0ff9d998cec64641c8f3e82611248626796fdb1b7a352afb95e2037b459b04e7599e263
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# Compo
|
2
2
|
|
3
|
-
|
3
|
+
**Compo** is a library providing mixins and base classes for setting up
|
4
|
+
composite objects.
|
5
|
+
|
6
|
+
It implements something similar to the Gang of Four Composite pattern, but with
|
7
|
+
the difference that children are identified in their parents by an *ID*,
|
8
|
+
such as the index or hash key, that the child is aware of at all times.
|
9
|
+
|
10
|
+
Compo was designed for the purpose of creating models whose natural composite
|
11
|
+
structure can be expressed as URLs made from their recursive ID trails.
|
4
12
|
|
5
13
|
## Installation
|
6
14
|
|
data/lib/compo/composite.rb
CHANGED
@@ -34,7 +34,7 @@ module Compo
|
|
34
34
|
#
|
35
35
|
# @return [Object] The added child if successful; nil otherwise.
|
36
36
|
def add(id, child)
|
37
|
-
add!(id, child).tap(&method(:
|
37
|
+
add!(id, child).tap(&method(:assign_parent_to))
|
38
38
|
end
|
39
39
|
|
40
40
|
# Removes a child from this Composite directly
|
@@ -50,7 +50,7 @@ module Compo
|
|
50
50
|
#
|
51
51
|
# @return [Object] The removed child if successful; nil otherwise.
|
52
52
|
def remove(child)
|
53
|
-
remove!(child).tap(&method(:
|
53
|
+
remove!(child).tap(&method(:remove_parent_of))
|
54
54
|
end
|
55
55
|
|
56
56
|
# Removes a child from this Composite, given its ID
|
@@ -66,7 +66,7 @@ module Compo
|
|
66
66
|
#
|
67
67
|
# @return [Object] The removed child if successful; nil otherwise.
|
68
68
|
def remove_id(id)
|
69
|
-
remove_id!(id).tap(&method(:
|
69
|
+
remove_id!(id).tap(&method(:remove_parent_of))
|
70
70
|
end
|
71
71
|
|
72
72
|
def_delegator :children, :each
|
@@ -83,7 +83,7 @@ module Compo
|
|
83
83
|
# @param child [Object] The child whose parent assignment is being set.
|
84
84
|
#
|
85
85
|
# @return [void]
|
86
|
-
def
|
86
|
+
def assign_parent_to(child)
|
87
87
|
child.update_parent(self, id_function(child)) unless child.nil?
|
88
88
|
end
|
89
89
|
|
@@ -96,7 +96,7 @@ module Compo
|
|
96
96
|
# @param child [Object] The child whose parent assignment is being set.
|
97
97
|
#
|
98
98
|
# @return [void]
|
99
|
-
def
|
99
|
+
def remove_parent_of(child)
|
100
100
|
child.remove_parent unless child.nil?
|
101
101
|
end
|
102
102
|
|
data/lib/compo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compo
|
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
|
- Matt Windsor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backports
|