SQLEngine/RecordSet/PKeySet.pm untested

filter: Statementstmt 0.0% 0 / 6 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 2 Podpod n/a totaltotal 0.0% 0 / 8 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 =head1 NAME
2  
3 DBIx::SQLEngine::RecordSet::PKeySet - A RecordSet which holds primary keys
4  
5 =head1 SYNOPSIS
6  
7 use DBIx::SQLEngine::RecordSet;
8
9 $rs = DBIx::SQLEngine::RecordSet->class( 'PKeySet' )->new(@records);
10  
11 =head1 DESCRIPTION
12  
13 Provides additional methods for a RecordSet to store primary keys instead of references to records.
14  
15 B<This package is INCOMPLETE!>
16  
17 =cut
18  
19 ########################################################################
20  
21 package DBIx::SQLEngine::RecordSet::PKeySet;
22  
23 use strict;
24 use Carp;
25  
26 ########################################################################
27  
28 =head2 Class and IDs
29  
30 =over 4
31  
32 =item *
33  
34 $rs = DBIx::SQLEngine::RecordSet::Set->new_class_ids( $class, @ids );
35  
36 =item *
37  
38 $rs->init_class_ids( $class, @ids );
39  
40 =item *
41  
42 ( $class, @ids ) = $rs->class_ids();
43  
44 =back
45  
46 =head2 Conversions
47  
48 Each of the below returns a RecordSet blessed into a particular subclass. Returns the original object if it is already of that subclass, or returns a cloned and converted copy.
49  
50 =over 4
51  
52 =item *
53  
54 @data = $rs->raw();
55  
56 Returns the contents of the RecordSet as stored internally within the object. Results are dependent on which subclass is in use.
57  
58 =item *
59  
60 $rs = $rs->as_RecordArray;
61  
62 INCOMPLETE
63  
64 =item *
65  
66 $clone = $rs->as_IDArray;
67  
68 INCOMPLETE
69  
70 =item *
71  
72 $clone = $rs->as_IDString;
73  
74 INCOMPLETE
75  
76 =back
77  
78 # $rs = DBIx::SQLEngine::RecordSet::Set->new_class_ids( $class, @ids );
79 sub new_ids {
80 my $callee = shift;
81 my $package = ref $callee || $callee;
82
83 my $self = [];
84 bless $self, $package;
85 $self->init_class_ids( @_ );
86 return $self;
87 }
88  
89 # $rs->init_ids( $class, @ids );
90 sub init_ids {
91 my $self = shift;
92 my $class = shift;
93
94 @$self = map { $class->fetch_id( $_ ) } @_;
95 }
96  
97 # @records = $rs->class_ids();
98 sub class_ids {
99 my $self = shift;
100 my $class = ref( $self->[0] );
101 return $class, map { $_->{id} } @$self;
102 }
103  
104 ###
105  
106 sub raw {
107 my $self = shift;
108 if ( scalar @_ ) {
109 @$self = @_;
110 } else {
111 @$self;
112 }
113 }
114 #
115 # sub as_RecordArray {
116 # my $self = shift;
117 # }
118 #
119 # sub as_IDArray {
120 # my $self = shift;
121 # EBiz::Database::RecordSet::IDArray->new( $self->records );
122 # }
123 #
124 # sub as_IDString {
125 # my $self = shift;
126 # EBiz::Database::RecordSet::IDString->new( $self->records );
127 # }
128  
129 ########################################################################
130  
131 ########################################################################
132  
133 =head1 SEE ALSO
134  
135 See L<DBIx::SQLEngine> for the overall interface and developer documentation.
136  
137 See L<DBIx::SQLEngine::Docs::ReadMe> for general information about
138 this distribution, including installation and license information.
139  
140 =cut
141  
142 ########################################################################
143  
144 1;