Smooth.pm

filter: Statementstmt 100% 11 / 11 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 14 / 14 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Smooth/Helper/Row/JoinTable.pm ↑ Summary Smooth/Lookup/DateTime.pm »
1 package DBIx::Class::Smooth;
2  
3 1 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # ABSTRACT: Sugar for DBIx::Class
8 1 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 1 our $VERSION = '0.0104';
10  
11 1 1;
12  
13 __END__
14  
15 =pod
16  
17 =encoding utf-8
18  
19 =head1 NAME
20  
21 DBIx::Class::Smooth - Sugar for DBIx::Class
22  
23  
24  
25 =begin html
26  
27 <p>
28 <img src="https://img.shields.io/badge/perl-5.20+-blue.svg" alt="Requires Perl 5.20+" />
29 <a href="https://travis-ci.org/Csson/p5-DBIx-Class-Smooth"><img src="https://api.travis-ci.org/Csson/p5-DBIx-Class-Smooth.svg?branch=master" alt="Travis status" /></a>
30 <a href="http://cpants.cpanauthors.org/release/CSSON/DBIx-Class-Smooth-0.0104"><img src="http://badgedepot.code301.com/badge/kwalitee/CSSON/DBIx-Class-Smooth/0.0104" alt="Distribution kwalitee" /></a>
31 <a href="http://matrix.cpantesters.org/?dist=DBIx-Class-Smooth%200.0104"><img src="http://badgedepot.code301.com/badge/cpantesters/DBIx-Class-Smooth/0.0104" alt="CPAN Testers result" /></a>
32 <img src="https://img.shields.io/badge/coverage-65.2%-red.svg" alt="coverage 65.2%" />
33 </p>
34  
35 =end html
36  
37 =head1 VERSION
38  
39 Version 0.0104, released 2020-08-30.
40  
41 =head1 SYNOPSIS
42  
43 #* The schema
44 package Your::Schema;
45  
46 use parent 'DBIx::Class::Smooth::Schema';
47  
48 __PACKAGE__->load_namespaces;
49  
50  
51 #* The project-specific DBIx::Class::Candy subclass
52 package Your::Schema::Result;
53  
54 use parent 'DBIx::Class::Smooth::Result';
55 sub base {
56 return $_[1] || 'Your::Schema::ResultBase';
57 }
58 sub default_result_namespace {
59 return 'Your::Schema::Result';
60 }
61  
62  
63 #* The project-specific base class for your result sources
64 package Your::Schema::ResultBase;
65  
66 use parent 'DBIx::Class::Smooth::ResultBase';
67 __PACKAGE__->load_components(qw/.../);
68  
69  
70 #* A couple of result source definitions
71 package Your::Schema::Result::Publisher;
72  
73 use Your::Schema::Result -components => [qw/.../];
74 use DBIx::Class::Smooth::Fields -all;
75  
76 primary id => IntegerField(auto_increment => true);
77 col name => VarcharField(size => 100);
78  
79  
80 package Your::Schema::Result::Book;
81  
82 use Your::Schema::Result -components => [qw/.../];
83 use DBIx::Class::Smooth::Fields -all;
84  
85 primary id => IntegerField(auto_increment => true);
86 belongs Publisher => ForeignKey();
87 col isbn => VarcharField(size => 13);
88 col title => VarcharField(size => 150);
89 col published_date => DateField();
90 col language => EnumField(indexed => 1, -list => [qw/english french german spanish/]);
91  
92  
93 #* The project-specific DBIx::Class::Candy::ResultSet subclass
94 package Your::Schema::ResultSet;
95  
96 use parent 'DBIx::Class::Smooth::ResultSet';
97  
98 sub base { $_[1] || 'Your::Schema::ResultSetBase' }
99  
100  
101 #* The project-specific base class for your resultsets
102 package Your::Schema::ResultSetBase;
103  
104 use parent 'DBIx::Class::Smooth::ResultSetBase';
105  
106 __PACKAGE__->load_components(qw/
107 Helper::ResultSet::DateMethods1
108 Smooth::Lookup::DateTime
109 /);
110  
111  
112 #* In the Book resultset
113 package Your::Schema::ResultSet::Book;
114  
115 use Your::Schema::ResultSet -components => [qw/.../];
116 use DBIx::Class::Smooth::Q;
117  
118 sub get_books_by_year($self, $year) {
119 return $self->filter(published_date__year => $year);
120 }
121 sub get_books_by_either_isbn_or_title($self, $isbn, $title) {
122 return $self->filter(Q(isbn => $isbn) | Q(title => $title));
123 }
124  
125  
126 #* Elsewhere, using the Book resultset
127 my $books = $schema->Book->get_books_by_year(2018);
128  
129 =head1 STATUS
130  
131 This is experimental, and an early release at that. I'm using this in a couple of non-critical personal projects, so it hasn't seen heavy use. It would not be surprising if there are bad bugs. Also, it's only been tested on MySQL/MariaDB.
132  
133 Documentation is expected to improve with time.
134  
135 =head1 DESCRIPTION
136  
137 DBIx::Class::Smooth is a sugar layer for L<DBIx::Class>, partially built on top of L<DBIx::Class::Candy> and L<DBIx::Class::Helpers>.
138  
139 =head1 MORE DOCUMENTATION
140  
141 for :list
142 * L<DBIx::Class::Smooth::Schema>
143 * L<DBIx::Class::Smooth::Fields>
144  
145 =head1 SOURCE
146  
147 L<https://github.com/Csson/p5-DBIx-Class-Smooth>
148  
149 =head1 HOMEPAGE
150  
151 L<https://metacpan.org/release/DBIx-Class-Smooth>
152  
153 =head1 AUTHOR
154  
155 Erik Carlsson <info@code301.com>
156  
157 =head1 COPYRIGHT AND LICENSE
158  
159 This software is copyright (c) 2018 by Erik Carlsson.
160  
161 This is free software; you can redistribute it and/or modify it under
162 the same terms as the Perl 5 programming language system itself.
163  
164 =cut
« Smooth/Helper/Row/JoinTable.pm ↑ Summary Smooth/Lookup/DateTime.pm »