line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::AuditAny::Util::SchemaMaker; |
2
|
10
|
|
|
10
|
|
49
|
use strict; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
239
|
|
3
|
10
|
|
|
10
|
|
34
|
use warnings; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
322
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# ABSTRACT: On-the-fly creation of DBIC Schema classes |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
DBIx::Class::AuditAny::Util::SchemaMaker - On-the-fly creation of DBIC Schema classes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This package provides an easy way to conjurer new DBIC schema classes into existence |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
10
|
|
|
10
|
|
36
|
use Moo; |
|
10
|
|
|
|
|
11
|
|
|
10
|
|
|
|
|
46
|
|
20
|
10
|
|
|
10
|
|
10083
|
use MooX::Types::MooseLike::Base qw(:all); |
|
10
|
|
|
|
|
16
|
|
|
10
|
|
|
|
|
2755
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#use Moose; |
23
|
|
|
|
|
|
|
#use MooseX::Types::Moose qw(HashRef ArrayRef Str Bool Maybe Object CodeRef); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
require Class::MOP::Class; |
26
|
10
|
|
|
10
|
|
52
|
use DBIx::Class::AuditAny::Util; |
|
10
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
824
|
|
27
|
10
|
|
|
10
|
|
3970
|
use DBIx::Class::AuditAny::Util::ResultMaker; |
|
10
|
|
|
|
|
24
|
|
|
10
|
|
|
|
|
2277
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head2 schema_namespace |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Required - the class name of the DBIC schema to be created |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=cut |
34
|
|
|
|
|
|
|
has 'schema_namespace', is => 'ro', isa => Str, required => 1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 class_opts |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Optional extra params to supply to C<< Class::MOP::Class->create >> |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=cut |
41
|
|
|
|
|
|
|
has 'class_opts', is => 'ro', isa => HashRef, default => sub {{}}; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 results |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
HashRef of key/value pairs defining the result/sources to be created. The key |
46
|
|
|
|
|
|
|
is the source name, while the value must be a HashRef to be supplied to the |
47
|
|
|
|
|
|
|
C<initialize> constructor of L<DBIx::Class::AuditAny::Util::ResultMaker>. The |
48
|
|
|
|
|
|
|
C<class_name> does not need to be specified here as it is automatically set |
49
|
|
|
|
|
|
|
according to the C<schema_namespace> and the source name (key value). |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
has 'results', is => 'ro', isa => HashRef[HashRef], required => 1; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 initialize |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Initialization constructor. Expects the above attrs as a HashRef as they would be passed to |
59
|
|
|
|
|
|
|
C<new()>. Creates the specified schema and associated result classes on-the-spot. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=cut |
62
|
|
|
|
|
|
|
sub initialize { |
63
|
10
|
|
|
10
|
1
|
948
|
my $self = shift; |
64
|
10
|
50
|
|
|
|
73
|
$self = $self->new(@_) unless (ref $self); |
65
|
|
|
|
|
|
|
|
66
|
10
|
|
|
|
|
1085
|
my $class = $self->schema_namespace; |
67
|
10
|
50
|
|
|
|
65
|
die "class/namespace '$class' already defined!" if (package_exists $class); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Class::MOP::Class->create($class, |
70
|
|
|
|
|
|
|
superclasses => [ 'DBIx::Class::Schema' ], |
71
|
10
|
50
|
|
|
|
34
|
%{ $self->class_opts } |
|
10
|
|
|
|
|
147
|
|
72
|
|
|
|
|
|
|
) or die $@; |
73
|
|
|
|
|
|
|
|
74
|
10
|
|
|
|
|
17798
|
my @Results = sort keys %{$self->results}; |
|
10
|
|
|
|
|
103
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
DBIx::Class::AuditAny::Util::ResultMaker->initialize( |
77
|
|
|
|
|
|
|
class_name => $class . '::' . $_, |
78
|
40
|
|
|
|
|
324
|
%{$self->results->{$_}} |
79
|
10
|
|
|
|
|
50
|
) for (@Results); |
80
|
|
|
|
|
|
|
|
81
|
10
|
|
|
|
|
110
|
$class->load_classes(@Results); |
82
|
|
|
|
|
|
|
|
83
|
10
|
|
|
|
|
17159
|
return $class; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=over |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=item * |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
L<DBIx::Class::AuditAny> |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=item * |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
L<DBIx::Class> |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=back |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 SUPPORT |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
IRC: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Join #rapidapp on irc.perl.org. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 AUTHOR |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Henry Van Styn <vanstyn@cpan.org> |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This software is copyright (c) 2012-2015 by IntelliTree Solutions llc. |
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 |