line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::AuditAny::Util::ResultMaker; |
2
|
10
|
|
|
10
|
|
38
|
use strict; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
250
|
|
3
|
10
|
|
|
10
|
|
35
|
use warnings; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
221
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: On-the-fly creation of DBIC Result classes |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
DBIx::Class::AuditAny::Util::ResultMaker - On-the-fly creation of DBIC Result classes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This package provides an easy way to conjurer new DBIC result classes into existence. It |
14
|
|
|
|
|
|
|
is typically used by L<DBIx::Class::AuditAny::Util::SchemaMaker> and not called directly. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
10
|
|
|
10
|
|
36
|
use Moo; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
44
|
|
21
|
10
|
|
|
10
|
|
10174
|
use MooX::Types::MooseLike::Base qw(:all); |
|
10
|
|
|
|
|
17
|
|
|
10
|
|
|
|
|
2638
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
require Class::MOP::Class; |
24
|
10
|
|
|
10
|
|
51
|
use DBIx::Class::AuditAny::Util; |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
3057
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 class_name |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
Required. Full class name of the result class to be created |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
has 'class_name', is => 'ro', isa => Str, required => 1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 class_opts |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Optional extra params to supply to C<< Class::MOP::Class->create >> |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
has 'class_opts', is => 'ro', isa => HashRef, default => sub {{}}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 table_name |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Required. The name of the table as would be supplied to C<< ->table() >> in the |
44
|
|
|
|
|
|
|
result class. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
has 'table_name', is => 'ro', isa => Str, required => 1; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 columns |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Required. ArrayRef of DBIC column definitions suitable as arguments for C<< ->add_columns() >> |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
has 'columns', is => 'ro', isa => ArrayRef, required => 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 call_class_methods |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Optional ArrayRef consumed in pairs, with the first value used as a method name, and the |
59
|
|
|
|
|
|
|
second value an ArrayRef holding the args to supply to the method. Each of these are called |
60
|
|
|
|
|
|
|
as class methods on the result class. This allows for any other calls to be handled, such as |
61
|
|
|
|
|
|
|
adding uniq keys, and so on. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
has 'call_class_methods', is => 'ro', isa => ArrayRef, default => sub {[]}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 METHODS |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 initialize |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Initialization constructor. Expects the above attrs as a HashRef as they would be passed to |
72
|
|
|
|
|
|
|
C<new()>. Creates the specified result class and invokes all the setup methods as defined above. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
sub initialize { |
76
|
40
|
|
|
40
|
1
|
57
|
my $self = shift; |
77
|
40
|
50
|
|
|
|
712
|
$self = $self->new(@_) unless (ref $self); |
78
|
|
|
|
|
|
|
|
79
|
40
|
|
|
|
|
2739
|
my $class = $self->class_name; |
80
|
40
|
50
|
|
|
|
145
|
die "class/namespace '$class' already defined!" if (package_exists $class); |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Class::MOP::Class->create($class, |
83
|
|
|
|
|
|
|
superclasses => [ 'DBIx::Class::Core' ], |
84
|
40
|
50
|
|
|
|
83
|
%{ $self->class_opts } |
|
40
|
|
|
|
|
227
|
|
85
|
|
|
|
|
|
|
) or die $@; |
86
|
|
|
|
|
|
|
|
87
|
40
|
|
|
|
|
55853
|
$class->table( $self->table_name ); |
88
|
|
|
|
|
|
|
|
89
|
40
|
|
|
|
|
14534
|
$class->add_columns( @{$self->columns} ); |
|
40
|
|
|
|
|
492
|
|
90
|
|
|
|
|
|
|
|
91
|
40
|
|
|
|
|
57716
|
my @call_list = @{$self->call_class_methods}; |
|
40
|
|
|
|
|
190
|
|
92
|
40
|
|
|
|
|
123
|
while (my $meth = shift @call_list) { |
93
|
90
|
|
|
|
|
7932
|
my $args = shift @call_list; |
94
|
90
|
|
|
|
|
1534
|
$class->$meth(@$args); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
40
|
|
|
|
|
10813
|
return $class; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
1; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
__END__ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SEE ALSO |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=over |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
L<DBIx::Class::AuditAny::Util::SchemaMaker> |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L<DBIx::Class::AuditAny> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
L<DBIx::Class> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 SUPPORT |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
IRC: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Join #rapidapp on irc.perl.org. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Henry Van Styn <vanstyn@cpan.org> |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
This software is copyright (c) 2012-2015 by IntelliTree Solutions llc. |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
137
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=cut |