SQLEngine/Record/Accessors.pm

filter: Statementstmt 100% 17 / 17 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 100% 1 / 1 totaltotal 92.5% 25 / 27 CC 3 SCAR 6.5
CC
3
Cov
90%
get_values
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.9
« test_cfg.pl ↑ Summary SQLEngine/Record/Table.pm »
1 =head1 NAME
2  
3 DBIx::SQLEngine::Record::Accessors - Add Methods for Columns
4  
5 =head1 SYNOPSIS
6  
7 B<Setup:> Several ways to create a class.
8  
9 my $sqldb = DBIx::SQLEngine->new( ... );
10  
11 $class_name = $sqldb->record_class( $table_name, undef, 'Accessors' );
12
13 $sqldb->record_class( $table_name, 'My::Record', 'Accessors' );
14
15 package My::Record;
16 use DBIx::SQLEngine::Record::Class '-isasubclass', 'Accessors';
17 My::Record->table( $sqldb->table($table_name) );
18  
19 B<Accessors:> Create methods for columns.
20
21 $class_name->install_accessors( %column_info );
22  
23  
24 =head1 DESCRIPTION
25  
26 This package provides automatic method generation for DBIx::SQLEngine::Record objects.
27  
28 Don't use this module directly; instead, pass its name as a trait when you create a new record class. This package provides a multiply-composable collection of functionality for Record classes. It is combined with the base class and other traits by DBIx::SQLEngine::Record::Class.
29  
30 This package is not yet complete.
31  
32 =cut
33  
34 ########################################################################
35  
36 package DBIx::SQLEngine::Record::Accessors;
37  
38 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 ########################################################################
42  
43 ########################################################################
44  
45 =head1 ACCESSORS INTERFACE
46  
47 =head2 Autoloader
48  
49 =over 4
50  
51 =item AUTOLOAD
52  
53 Provided by Class::MakeMethods::Autoload. Generates scalar accessor methods using Class::MakeMethods::Standard::Hash.
54  
55 =back
56  
57 =cut
58  
59 1 ▶use Class::MakeMethods::Autoload 'Standard::Hash:scalar';
Subroutine BEGIN: called CC=1 SCAR=0.0
60  
61 ########################################################################
62  
63 ########################################################################
64  
65 =head1 SIMPLE RECORD INTERFACE
66  
67 =head2 Getting and Changing Values
68  
69 Simple interface for applying changes.
70  
71 =over 4
72  
73 =item get_values()
74  
75 $record->get_values( key1 ) : $value
76 $record->get_values( key1, key2, ... ) : $values_joined_with_comma
77 $record->get_values( key1, key2, ... ) : @values
78  
79 Returns the values associated with the keys in the provided record.
80  
81 =item change_values
82  
83 $record->change_values( method1 => value1, ... );
84  
85 Call provided method names with supplied values.
86 (Class::MakeMethods::Standard::Universal:call_methods).
87  
88 =back
89  
90 =cut
91  
92 2 ▶sub get_values {
Subroutine get_values: called CC=3 SCAR=11.4
Pod documented
93 2 my $self = shift;
94 2 ▶ ref($self) or croak("Can't call this object method on a record class");
Branch: 1 branch
BranchTrueFalseTotal
ref $self or croak("Can't call this object method on a record class") 2 0 2
95 2 my @values = map $self->$_(), @_;
96 2 ▶ wantarray ? @values : join(', ', @values)
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 2 2
97 }
98  
99 1 ▶use Class::MakeMethods (
Subroutine BEGIN: called CC=1 SCAR=0.0
100 1 'Standard::Universal:call_methods' => 'change_values',
101 1 );
102  
103 ########################################################################
104  
105 ########################################################################
106  
107 =head1 SEE ALSO
108  
109 For more about the Record classes, see L<DBIx::SQLEngine::Record::Class>.
110  
111 See L<DBIx::SQLEngine> for the overall interface and developer documentation.
112  
113 See L<DBIx::SQLEngine::Docs::ReadMe> for general information about
114 this distribution, including installation and license information.
115  
116 =cut
117  
118 ########################################################################
119  
120 1 1;
« test_cfg.pl ↑ Summary SQLEngine/Record/Table.pm »