| 1 | # $Id: LazyInflate.pm 7 2005-06-01 06:36:24Z daisuke $ | ||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||
| 3 | # Copyright (c) 2004-2005 Daisuke Maki <dmaki@cpan.org> | ||||||||||||||||||||||||||||
| 4 | # All rights reserved. | ||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | package Class::DBI::LazyInflate; | ||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Class::DBI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Lazy; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | BEGIN | ||||||||||||||||||||||||||||
| 13 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | $VERSION = '0.06'; | |||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub import | ||||||||||||||||||||||||||||
| 18 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 20 | 1 | my($caller) = caller(); | |||||||||||||||||||||||||||
| 21 | { | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 1 | *{ "${caller}::has_lazy" } = \&has_lazy; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | sub has_lazy | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
has_lazy: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 29 | 0 | my($class, $column, $colclass, %args) = @_; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | my $inflate = $args{inflate} || | ||||||||||||||||||||||||||||
| 32 | 0 | ▶ | ($colclass->isa('Class::DBI') ? '_simple_bless' : 'new'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{'inflate'} || ($colclass->isa('Class::DBI') ? '_simple_bless' : 'new')
MC/DC0%0/2
$args{'inflate'} || ($colclass->isa('Class::DBI') ? '_simple_bless' : 'new')
$args{'inflate'}
($colclass->isa('Class::DBI') ? '_simple_bless' : 'new')
Truth table0%0/3
A || B
A= $args{'inflate'}B= ($colclass->isa('Class::DBI') ? '_simple_bless' : 'new')
| |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | my $lazy_inflate = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 34 | 0 | my @args = @_; | |||||||||||||||||||||||||||
| 35 | tie $_[0], 'Data::Lazy', | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | ref($inflate) eq 'CODE' ? | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | $inflate->(@args) : | ||||||||||||||||||||||||||||
| 39 | $colclass->$inflate(@args) }, | ||||||||||||||||||||||||||||
| 40 | 0 | LAZY_STOREVALUE; | |||||||||||||||||||||||||||
| 41 | 0 | $_[0]; | |||||||||||||||||||||||||||
| 42 | 0 | }; | |||||||||||||||||||||||||||
| 43 | $class->has_a( | ||||||||||||||||||||||||||||
| 44 | $column, $colclass, | ||||||||||||||||||||||||||||
| 45 | inflate => $lazy_inflate, deflate => $args{deflate} | ||||||||||||||||||||||||||||
| 46 | 0 | ); | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 1 | 1; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | __END__ | ||||||||||||||||||||||||||||