parallel-ancestry 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -4,3 +4,6 @@
4
4
  Initial release abstracted to be entirely independent from cascading-configuration.
5
5
  Replaces cascading-configuration-inheritance and cascading-configuration-ancestors without any cascading-configuration dependencies.
6
6
 
7
+ == 6/11/2012
8
+
9
+ Added YARD docs.
@@ -27,6 +27,9 @@ module ::ParallelAncestry
27
27
  # children #
28
28
  ##############
29
29
 
30
+ # Return a list of children for provided object.
31
+ # @param [Object] instance Object instance.
32
+ # @return [Array<Object>] An array containing references to children.
30
33
  def children( instance )
31
34
 
32
35
  return children_hash( instance ).keys
@@ -37,6 +40,9 @@ module ::ParallelAncestry
37
40
  # parents #
38
41
  #############
39
42
 
43
+ # Return a list of parents for provided object.
44
+ # @param [Object] instance Object instance.
45
+ # @return [Array<Object>] An array containing references to immediate parents for any configuration.
40
46
  def parents( instance )
41
47
 
42
48
  return parents_array( instance )
@@ -47,6 +53,9 @@ module ::ParallelAncestry
47
53
  # has_parents? #
48
54
  ##################
49
55
 
56
+ # Return whether provided object has parents.
57
+ # @param [Object] instance Object instance.
58
+ # @return [true, false] true or false.
50
59
  def has_parents?( instance )
51
60
 
52
61
  has_parents = false
@@ -65,6 +74,9 @@ module ::ParallelAncestry
65
74
  # has_children? #
66
75
  ###################
67
76
 
77
+ # Return whether provided object has children.
78
+ # @param [Object] instance Object instance.
79
+ # @return [true, false] true or false.
68
80
  def has_children?( instance )
69
81
 
70
82
  has_children = false
@@ -83,6 +95,10 @@ module ::ParallelAncestry
83
95
  # register_child_for_parent #
84
96
  ###############################
85
97
 
98
+ # Register instance as child of another instance.
99
+ # @param [Object] child Child instance.
100
+ # @param [Object] parent Parent instance.
101
+ # @return [Array<Object>] An array containing references to children.
86
102
  def register_child_for_parent( child, parent )
87
103
 
88
104
  parents_of_child_hash = parents_hash( child )
@@ -107,6 +123,19 @@ module ::ParallelAncestry
107
123
  # ancestor #
108
124
  ##############
109
125
 
126
+ # Return parent for instance that matches match_ancestor_block.
127
+ # @param [Object] instance Child instance.
128
+ # @yield Block used to match parent. The parameter is the parent instance, the return value true
129
+ # or false, reflecting whether or not block matched ancestor.
130
+ # @example
131
+ # ::ParallelAncestry.ancestor( some_instance ) do |this_parent|
132
+ # if this_parent.matches_arbitrary_condition
133
+ # true
134
+ # else
135
+ # false
136
+ # end
137
+ # end
138
+ # @return [Object] A reference to parent matching block condition.
110
139
  def ancestor( instance, & match_ancestor_block )
111
140
 
112
141
  ancestor_instance = nil
@@ -137,10 +166,25 @@ module ::ParallelAncestry
137
166
 
138
167
  end
139
168
 
169
+ alias_method :parent, :ancestor
170
+
140
171
  ####################
141
172
  # ancestor_chain #
142
173
  ####################
143
174
 
175
+ # Returns ancestor chain defined for provided object.
176
+ # @param [Object] instance Instance for which ancestors are being looked up.
177
+ # @yield Block used to match parent. The parameter is the parent instance, the return value true
178
+ # or false, reflecting whether or not block matched ancestor.
179
+ # @example
180
+ # ::ParallelAncestry.ancestor( some_instance ) do |this_parent|
181
+ # if this_parent.matches_arbitrary_condition
182
+ # true
183
+ # else
184
+ # false
185
+ # end
186
+ # end
187
+ # @return [Array<Object>] An array containing references to parents matching block condition.
144
188
  def ancestor_chain( instance, & match_ancestor_block )
145
189
 
146
190
  ancestor_chain = [ this_ancestor = instance ]
@@ -157,6 +201,22 @@ module ::ParallelAncestry
157
201
  # lowest_parents #
158
202
  ####################
159
203
 
204
+ # Returns the lowest parent in each parent tree matching block condition. For simple linear
205
+ # trees, this is simply the first parent, but more complex trees quickly diverge into multiple
206
+ # branches, each of which then requires a lowest match.
207
+ # @param [Object] instance Instance for which parents are being looked up.
208
+ # @yield Block used to match parent. The parameter is the parent instance, the return value true
209
+ # or false, reflecting whether or not block matched ancestor.
210
+ # @example
211
+ # ::ParallelAncestry.lowest_parents( some_instance ) do |this_parent|
212
+ # if this_parent.matches_arbitrary_condition
213
+ # true
214
+ # else
215
+ # false
216
+ # end
217
+ # end
218
+ # @return [Array<Object>] An array containing references to lowest parent in each parent tree
219
+ # matching block condition.
160
220
  def lowest_parents( instance, & match_ancestor_block )
161
221
 
162
222
  # the first super module available for each tree
@@ -189,6 +249,22 @@ module ::ParallelAncestry
189
249
  # highest_children #
190
250
  ######################
191
251
 
252
+ # Returns the highest parent in each parent tree matching block condition. For simple linear
253
+ # trees, this is simply the first parent, but more complex trees quickly diverge into multiple
254
+ # branches, each of which then requires a highest match.
255
+ # @param [Object] instance Instance for which parents are being looked up.
256
+ # @yield Block used to match parent. The parameter is the parent instance, the return value true
257
+ # or false, reflecting whether or not block matched ancestor.
258
+ # @example
259
+ # ::ParallelAncestry.highest_parents( some_instance ) do |this_parent|
260
+ # if this_parent.matches_arbitrary_condition
261
+ # true
262
+ # else
263
+ # false
264
+ # end
265
+ # end
266
+ # @return [Array<Object>] An array containing references to highest parent in each parent tree
267
+ # matching block condition.
192
268
  def highest_children( instance, & match_ancestor_block )
193
269
 
194
270
  # the first super module available for each tree
@@ -221,6 +297,30 @@ module ::ParallelAncestry
221
297
  # match_ancestor_searching_upward #
222
298
  #####################################
223
299
 
300
+ # Returns the first ancestor (determined by ancestor_match_block) for which match_block is true.
301
+ # @param [Object] instance Instance for which parents are being looked up.
302
+ # @param [Proc] ancestor_match_block Proc used to match parent. The parameter is the parent
303
+ # instance, the return value true or false, reflecting whether or not block matched
304
+ # ancestor.
305
+ # @yield Block used to match parent. The parameter is the parent instance, the return value true
306
+ # or false, reflecting whether or not block matched.
307
+ # @example
308
+ # ancestor_match_block = ::Proc.new do |this_parent|
309
+ # if this_parent.matches_arbitrary_condition
310
+ # true
311
+ # else
312
+ # false
313
+ # end
314
+ # end
315
+ # ::ParallelAncestry.match_ancestor_searching_upward( some_instance,
316
+ # ancestor_match_block ) do |this_parent|
317
+ # if this_parent.matches_arbitrary_condition
318
+ # true
319
+ # else
320
+ # false
321
+ # end
322
+ # end
323
+ # @return [Object]
224
324
  def match_ancestor_searching_upward( instance, ancestor_match_block, & match_block )
225
325
 
226
326
  matched_value = nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel-ancestry
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -79,3 +79,4 @@ summary: Provides parallel implementations of inheritance hierarchies. This is u
79
79
  both for tracking the existing inheritance tree and for creating trees that function
80
80
  independently of inheritance models determined internal to Ruby.
81
81
  test_files: []
82
+ has_rdoc: