Dagnabit C0 Coverage Information - RCov

lib/dagnabit/link/named_scopes.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/dagnabit/link/named_scopes.rb 65 14
100.00%
100.00%

Key

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.

Coverage Details

1 module Dagnabit
2   module Link
3     #
4     # Adds named scopes to Link models.
5     #
6     # This module provides two named scopes for finding links scoped by
7     # ancestor and descendant type.  They were designed as support for node
8     # neighbor queries such as ancestors_of_type and descendants_as_type, but
9     # can be used on their own.
10     #
11     # These links are imported into the generated transitive closure link model.
12     # See Dagnabit::Link::TransitiveClosureLinkModel for more information.
13     #
14     # == Supplied scopes
15     #
16     # [ancestor_type]
17     #   Returns all links having a specified ancestor type.
18     #
19     # [descendant_type]
20     #   Returns all links having a specified descendant type.
21     #
22     # == A note on type matching
23     #
24     # Types are stored in links using ActiveRecord's polymorphic association
25     # typing logic, and are matched using string matching.  Therefore, subclass
26     # matching and namespacing aren't provided.
27     #
28     # To elaborate on this, let's say you have the following model structure:
29     #
30     #   class Link < ActiveRecord::Base
31     #     acts_as_dag_link
32     #   end
33     #
34     #   module Foo
35     #     class Bar < ActiveRecord::Base
36     #       ...
37     #     end
38     #   end
39     #
40     # A link linking Foo::Bars will record Foo::Bar as ancestor or descendant
41     # type, not just 'Bar'.  The following will therefore not work:
42     #
43     #   Link.ancestor_type('Bar')
44     #
45     # You have to do:
46     #
47     #   Link.ancestor_type('Foo::Bar')
48     #
49     # or, if you'd like to hide the details of deriving a full class name:
50     #
51     #   Link.ancestor_type(Bar.name)
52     #
53     module NamedScopes
54       def self.extended(base)
55         base.send(:named_scope,
56                   :ancestor_type,
57                   lambda { |type| { :conditions => { :ancestor_type => type } } })
58 
59         base.send(:named_scope,
60                   :descendant_type,
61                   lambda { |type| { :conditions => { :descendant_type => type } } })
62       end
63     end
64   end
65 end

Generated on Tue Dec 08 04:06:14 -0600 2009 with rcov 0.9.6