line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Fey::Object::Policy; |
2
|
|
|
|
|
|
|
|
3
|
10
|
|
|
10
|
|
44
|
use strict; |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
523
|
|
4
|
10
|
|
|
10
|
|
45
|
use warnings; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
248
|
|
5
|
10
|
|
|
10
|
|
40
|
use namespace::autoclean; |
|
10
|
|
|
|
|
13
|
|
|
10
|
|
|
|
|
61
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.47'; |
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
4138
|
use Fey::ORM::Types qw( ArrayRef CodeRef HashRef ); |
|
10
|
|
|
|
|
28
|
|
|
10
|
|
|
|
|
95
|
|
10
|
10
|
|
|
10
|
|
54971
|
use List::Util qw( first ); |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
952
|
|
11
|
|
|
|
|
|
|
|
12
|
10
|
|
|
10
|
|
65
|
use Moose; |
|
10
|
|
|
|
|
64
|
|
|
10
|
|
|
|
|
105
|
|
13
|
10
|
|
|
10
|
|
75020
|
use MooseX::StrictConstructor; |
|
10
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
278
|
|
14
|
10
|
|
|
10
|
|
36386
|
use MooseX::SemiAffordanceAccessor; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
101
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '_transforms' => ( |
17
|
|
|
|
|
|
|
traits => ['Array'], |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => ArrayRef [HashRef], |
20
|
|
|
|
|
|
|
default => sub { [] }, |
21
|
|
|
|
|
|
|
init_arg => undef, |
22
|
|
|
|
|
|
|
handles => { |
23
|
|
|
|
|
|
|
add_transform => 'push', |
24
|
|
|
|
|
|
|
transforms => 'elements', |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'has_one_namer' => ( |
29
|
|
|
|
|
|
|
is => 'rw', |
30
|
|
|
|
|
|
|
isa => CodeRef, |
31
|
|
|
|
|
|
|
default => \&_dumb_namer, |
32
|
|
|
|
|
|
|
required => 1, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'has_many_namer' => ( |
36
|
|
|
|
|
|
|
is => 'rw', |
37
|
|
|
|
|
|
|
isa => CodeRef, |
38
|
|
|
|
|
|
|
default => \&_dumb_namer, |
39
|
|
|
|
|
|
|
required => 1, |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub transform_for_column { |
43
|
79
|
|
|
79
|
1
|
2808
|
my $self = shift; |
44
|
79
|
|
|
|
|
151
|
my $column = shift; |
45
|
|
|
|
|
|
|
|
46
|
79
|
|
|
2
|
|
3806
|
return first { $_->{matching}->($column) } $self->transforms(); |
|
2
|
|
|
|
|
7
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub _dumb_namer { |
50
|
4
|
|
|
4
|
|
112
|
return sub { lc $_[0]->name() }; |
|
108
|
|
|
108
|
|
3394
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# ABSTRACT: An object representing a specific policy |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=pod |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 NAME |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Fey::Object::Policy - An object representing a specific policy |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 VERSION |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
version 0.47 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This class provides the non-sugar half of L<Fey::ORM::Policy>. It's |
74
|
|
|
|
|
|
|
probably not interesting unless you're interested in the guts of how |
75
|
|
|
|
|
|
|
L<Fey::ORM> works. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 METHODS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
This class accepts the following methods: |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head2 $policy->add_transform( matching => sub { ... }, inflate => sub { ... }, deflate => sub { ... } ) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Stores a transform as declared in L<Fey::ORM::Policy> |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 $policy->transform_for_column($column) |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Given a L<Fey::Column>, returns the first transform (as a hash |
88
|
|
|
|
|
|
|
reference) for which the C<matching> sub returns true. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 $policy->transforms() |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns all of the transforms for the policy. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 $policy->has_one_namer() |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Returns the naming sub for C<has_one()> methods. Defaults to: |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub { lc $_[0]->name() } |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 $policy->set_has_one_namer($sub) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Sets the naming sub for C<has_one()> methods. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 $policy->has_many_namer() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the naming sub for C<has_many()> methods. Defaults to: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub { lc $_[0]->name() } |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 $policy->set_has_many_namer($sub) |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Sets the naming sub for C<has_many()> methods. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 AUTHOR |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This software is copyright (c) 2011 - 2015 by Dave Rolsky. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
123
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |