| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| lib/dagnabit/node/neighbors.rb | 73 | 30 | 100.00%
|
100.00%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 module Dagnabit |
2 module Node |
3 # |
4 # Instance methods for finding out the neighbors of a node. |
5 # |
6 # These methods do _not_ behave like association proxies: they're just |
7 # wrappers around <tt>ActiveRecord::Base#find</tt>. Therefore, they do not |
8 # cache, do not support calculations, do not support extension modules, |
9 # named scopes, etc. |
10 # |
11 # These methods aren't association proxies because a link's ancestor and |
12 # descendant are polymorphic associations, and ActiveRecord does not |
13 # support polymorphic has_many :through associations. |
14 # |
15 module Neighbors |
16 # |
17 # Finds the parents (immediate predecessors) of this node. |
18 # |
19 def parents |
20 links_as_child.find(:all, :include => :ancestor).map { |l| l.ancestor } |
21 end |
22 |
23 # |
24 # Finds the parents (immediate predecessors) of this node satisfying a given type. |
25 # |
26 def parents_of_type(type) |
27 links_as_child.ancestor_type(type).find(:all, :include => :ancestor).map { |l| l.ancestor } |
28 end |
29 |
30 # |
31 # Finds the children (immediate successors) of this node. |
32 # |
33 def children |
34 links_as_parent.find(:all, :include => :descendant).map { |l| l.descendant } |
35 end |
36 |
37 # |
38 # Finds the children (immediate successors) of this node satisfying a given type. |
39 # |
40 def children_of_type(type) |
41 links_as_parent.descendant_type(type).find(:all, :include => :descendant).map { |l| l.descendant } |
42 end |
43 |
44 # |
45 # Find the ancestors (predecessors) of this node. |
46 # |
47 def ancestors |
48 links_as_descendant.find(:all, :include => :ancestor).map { |l| l.ancestor } |
49 end |
50 |
51 # |
52 # Find the ancestors (predecessors) of this node satisfying a given type. |
53 # |
54 def ancestors_of_type(type) |
55 links_as_descendant.ancestor_type(type).find(:all, :include => :ancestor).map { |l| l.ancestor } |
56 end |
57 |
58 # |
59 # Finds the descendants (successors) of this node. |
60 # |
61 def descendants |
62 links_as_ancestor.find(:all, :include => :descendant).map { |l| l.descendant } |
63 end |
64 |
65 # |
66 # Finds the descendants (successors) of this node satisfying a given type. |
67 # |
68 def descendants_of_type(type) |
69 links_as_ancestor.descendant_type(type).find(:all, :include => :descendant).map { |l| l.descendant } |
70 end |
71 end |
72 end |
73 end |
Generated on Tue Dec 08 04:06:14 -0600 2009 with rcov 0.9.6