line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
589704
|
use 5.20.0; |
|
2
|
|
|
|
|
22
|
|
2
|
2
|
|
|
2
|
|
9
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
33
|
|
3
|
2
|
|
|
2
|
|
9
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
128
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package DBIx::Class::Smooth::Schema; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Short intro |
8
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY |
9
|
|
|
|
|
|
|
our $VERSION = '0.0102'; |
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
12
|
use parent 'DBIx::Class::Schema'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
12
|
2
|
|
|
2
|
|
83628
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
87
|
|
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
814
|
use experimental qw/postderef signatures/; |
|
2
|
|
|
|
|
5721
|
|
|
2
|
|
|
|
|
11
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $dbix_class_smooth_methods_created = 0; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
2
|
1
|
2638
|
sub connection($self, @rest) { |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
3
|
|
19
|
2
|
|
|
|
|
13
|
$self = $self->next::method(@rest); |
20
|
|
|
|
|
|
|
|
21
|
2
|
50
|
|
|
|
97617
|
if(!$dbix_class_smooth_methods_created) { |
22
|
2
|
|
|
|
|
15
|
$self->_dbix_class_smooth_create_methods(); |
23
|
|
|
|
|
|
|
} |
24
|
2
|
|
|
|
|
11
|
return $self; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
6
|
sub _dbix_class_smooth_create_methods($self) { |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
4
|
|
28
|
2
|
|
|
2
|
|
591
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
597
|
|
29
|
2
|
|
|
|
|
13
|
for my $source (sort $self->sources) { |
30
|
8
|
|
|
|
|
114
|
(my $method = $source) =~ s{::}{_}g; |
31
|
|
|
|
|
|
|
|
32
|
8
|
50
|
|
|
|
60
|
if($self->can($method)) { |
33
|
0
|
|
|
|
|
0
|
croak(caller(1) . " already has a method named <$method>."); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
43
|
*{ caller(1) . "::$method" } = sub { |
37
|
5
|
|
|
5
|
|
3832
|
my $rs = shift->resultset($source); |
38
|
|
|
|
|
|
|
|
39
|
5
|
0
|
0
|
|
|
4459
|
return !scalar @_ ? $rs |
|
|
0
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
40
|
|
|
|
|
|
|
: defined $_[0] && !ref $_[0] ? $rs->find(@_) |
41
|
|
|
|
|
|
|
: ref $_[0] eq 'ARRAY' ? $rs->find(@$_[1..$#_], { key => $_->[0] }) |
42
|
|
|
|
|
|
|
: $rs->search(@_) |
43
|
|
|
|
|
|
|
; |
44
|
8
|
|
|
|
|
28
|
}; |
45
|
|
|
|
|
|
|
} |
46
|
2
|
|
|
|
|
6
|
$dbix_class_smooth_methods_created = 1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=pod |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=encoding UTF-8 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 NAME |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
DBIx::Class::Smooth::Schema - Short intro |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 VERSION |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Version 0.0102, released 2019-12-22. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# in MyApp::Schema, instead of inheriting from DBIx::Class::Schema |
69
|
|
|
|
|
|
|
use parent 'DBIx::Class::Smooth::Schema'; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 DESCRIPTION |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
DBIx::Class::Smooth::Schema adds method accessors for all resultsets. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
In short, instead of this: |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $schema = MyApp::Schema->connect(...); |
78
|
|
|
|
|
|
|
my $result = $schema->resultset('Author'); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
You can do this: |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
my $schema = MyApp::Schema->connect(...); |
83
|
|
|
|
|
|
|
my $result = $schema->Author; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 What is returned? |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The resultset methods can be called in four different ways. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head3 Without arguments |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# $schema->resultset('Author') |
92
|
|
|
|
|
|
|
$schema->Author; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head3 With a scalar |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# $schema->resultset('Author')->find(5) |
97
|
|
|
|
|
|
|
$schema->Author(5); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head3 With an array reference |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# $schema->resultset('Book')->find({ author => 'J.R.R Tolkien', title => 'The Hobbit' }, { key => 'book_author_title' }); |
102
|
|
|
|
|
|
|
$schema->Book([book_author_title => { author => 'J.R.R Tolkien', title => 'The Hobbit' }]); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head3 With anything else |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# $schema->resultset('Author')->search({ last_name => 'Tolkien'}, { order_by => { -asc => 'first_name' }}); |
107
|
|
|
|
|
|
|
$schema->Author({ last_name => 'Tolkien'}, { order_by => { -asc => 'first_name' }}); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SEE ALSO |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=over 4 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
L<DBIx::Class::Smooth> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 SOURCE |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
L<https://github.com/Csson/p5-DBIx-Class-Smooth> |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 HOMEPAGE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
L<https://metacpan.org/release/DBIx-Class-Smooth> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 AUTHOR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
Erik Carlsson <info@code301.com> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
This software is copyright (c) 2018 by Erik Carlsson. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
136
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=cut |