Meta/Role/Relationship.pm

filter: Statementstmt 100% 26 / 26 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 100% 32 / 32 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Meta/HasMany/ViaSelect.pm ↑ Summary ORM/Types.pm »
1 package Fey::Meta::Role::Relationship;
2 {
3 10 $Fey::Meta::Role::Relationship::VERSION = '0.46';
4 }
5  
6 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 10 ▶use Fey::ORM::Types qw( Bool CodeRef Str TableWithSchema );
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 10 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 10 has associated_class => (
15 is => 'rw',
16 isa => 'Fey::Meta::Class::Table',
17 writer => '_set_associated_class',
18 clearer => '_clear_associated_class',
19 weak_ref => 1,
20 init_arg => undef,
21 );
22  
23 10 has name => (
24 is => 'ro',
25 isa => Str,
26 lazy => 1,
27 builder => '_build_name',
28 );
29  
30 10 has namer => (
31 is => 'ro',
32 isa => CodeRef,
33 required => 1,
34 );
35  
36 10 has table => (
37 is => 'ro',
38 isa => TableWithSchema,
39 required => 1,
40 );
41  
42 10 has foreign_table => (
43 is => 'ro',
44 isa => TableWithSchema,
45 required => 1,
46 );
47  
48 10 has is_cached => (
49 is => 'ro',
50 isa => Bool,
51 lazy => 1,
52 builder => '_build_is_cached',
53 );
54  
55 sub _build_name {
56 4 ▶ my $self = shift;
Subroutine _build_name: called CC=1 SCAR=0.0
57  
58 4 return $self->namer()->( $self->foreign_table(), $self );
59 }
60  
61 10 1;
62  
63 # ABSTRACT: A shared role for all foreign HasX metaclasses
64  
65 __END__
66  
67 =pod
68  
69 =head1 NAME
70  
71 Fey::Meta::Role::Relationship - A shared role for all foreign HasX metaclasses
72  
73 =head1 VERSION
74  
75 version 0.46
76  
77 =head1 DESCRIPTION
78  
79 This role provides shared functionality for has-one and has-many
80 metaclasses. See the relevant classes for documentation.
81  
82 =head1 CONSTRUCTOR OPTIONS
83  
84 This role adds the following constructor options:
85  
86 =over 4
87  
88 =item * name
89  
90 The name of the relationship. This will be used as the name for any
91 attribute or method created by this metaclass.
92  
93 This defaults to C<< lc $self->foreign_table()->name() >>.
94  
95 =item * table
96  
97 The (source) table of the foreign key.
98  
99 =item * foreign_table
100  
101 The foreign table for the foreign key
102  
103 =item * is_cached
104  
105 Determines whether the relationship's value is cached. This is
106 implemented in different ways for has-one vs has-many relationships.
107  
108 =back
109  
110 =head1 AUTHOR
111  
112 Dave Rolsky <autarch@urth.org>
113  
114 =head1 COPYRIGHT AND LICENSE
115  
116 This software is copyright (c) 2011 by Dave Rolsky.
117  
118 This is free software; you can redistribute it and/or modify it under
119 the same terms as the Perl 5 programming language system itself.
120  
121 =cut
« Meta/HasMany/ViaSelect.pm ↑ Summary ORM/Types.pm »