File Coverage

blib/lib/Mandel/Relationship.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 8 8 100.0


line stmt bran cond sub pod time code
1             package Mandel::Relationship;
2 4     4   2041 use Mojo::Base -base;
  4         12  
  4         32  
3 4     4   636 use Mojo::Loader 'load_class';
  4         8  
  4         923  
4              
5             has accessor => '';
6             has document_class => '';
7             has foreign_field => sub { shift->document_class->model->name };
8             has related_class => '';
9              
10             # is this a bad memory leak? $model => $rel_obj => $_related_model
11             # i don't think so, since the number of objects are constant
12             has _related_model => sub {
13             my $self = shift;
14             my $e = load_class($self->related_class);
15             die $e if ref $e;
16             $self->related_class->model;
17             };
18              
19             1;
20              
21             =encoding utf8
22              
23             =head1 NAME
24              
25             Mandel::Relationship - Base class for relationships
26              
27             =head1 DESCRIPTION
28              
29             L is the base class for the following classes:
30              
31             =over 4
32              
33             =item * L
34              
35             =item * L
36              
37             =item * L
38              
39             =back
40              
41             =head1 ATTRIBUTES
42              
43             =head2 accessor
44              
45             Base name of accessor(s) created.
46              
47             =head2 foreign_field
48              
49             The name of the field in the foreign class which hold the "_id".
50              
51             =head2 document_class
52              
53             Holds the classname of the document class that holds all the accessors and
54             methods created.
55              
56             =head2 related_class
57              
58             Holds the related document class name.
59              
60             =head1 SEE ALSO
61              
62             L, L, L
63              
64             =head1 AUTHOR
65              
66             Jan Henning Thorsen - C
67              
68             =cut