lib/HTML/Mason/ComponentSource.pm

filter: Statementstmt 95.1% 39 / 41 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 91.6% 11 / 12 Podpod 75.0% 3 / 4 totaltotal 91.8% 56 / 61 CC 3 SCAR 3.7
CC
3
Cov
93%
comp_source_ref
3.0
__ANON__
1.1
BEGIN
1.0
CRAP 1.4
« lib/HTML/Mason/Escapes.pm ↑ Summary lib/HTML/Mason.pm »
1 # Copyright (c) 1998-2005 by Jonathan Swartz. All rights reserved.
2 # This program is free software; you can redistribute it and/or modify it
3 # under the same terms as Perl itself.
4  
5 package HTML::Mason::ComponentSource;
6 33 $HTML::Mason::ComponentSource::VERSION = '1.60';
7 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 33 ▶use File::Basename;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 33 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 33 ▶use HTML::Mason::Exceptions( abbr => [qw(param_error error)] );
Subroutine BEGIN: called CC=1 SCAR=0.0
12 33 ▶use Params::Validate qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 0 ▶Params::Validate::validation_options( on_fail => sub { param_error join '', @_ } );
Subroutine __ANON__: not called CC=1 SCAR=1.2
14  
15 # for reference later
16 #
17 # BEGIN
18 # {
19 # __PACKAGE__->valid_params
20 # (
21 # comp_id => { type => SCALAR | UNDEF, public => 0 },
22 # friendly_name => { type => SCALAR, public => 0 },
23 # last_modified => { type => SCALAR, public => 0 },
24 # comp_path => { type => SCALAR, public => 0 },
25 # comp_class => { isa => 'HTML::Mason::Component',
26 # default => 'HTML::Mason::Component',
27 # public => 0 },
28 # extra => { type => HASHREF, default => {}, public => 0 },
29 # source_callback => { type => CODEREF, public => 0 },
30 # );
31 # }
32  
33 use HTML::Mason::MethodMaker
34 33 ▶ ( read_only => [ qw( comp_id
Subroutine BEGIN: called CC=1 SCAR=0.0
35 friendly_name
36 last_modified
37 comp_path
38 comp_class
39 extra
40 ) ],
41 33 );
42  
43 33 my %defaults = ( comp_class => 'HTML::Mason::Component' );
44  
45 sub new
46 1211 ▶{
Subroutine new: called CC=1 SCAR=0.0
Pod documented
47 1211 my $class = shift;
48  
49 1211 return bless { %defaults, @_ }, $class
50 }
51  
52 sub comp_source_ref
53 589 ▶{
Subroutine comp_source_ref: called CC=3 SCAR=11.1
Pod undocumented
54 589 my $self = shift;
55  
56 589 my $source = eval { $self->{source_callback}->() };
57  
58 589 rethrow_exception $@;
59  
60 588 ▶ unless ( defined $source )
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $source) 0 588 588
61 {
62 0 error "source callback returned no source for $self->{friendly_name} component";
63 }
64  
65 588 ▶ my $sourceref = ref($source) ? $source : \$source;
Branch: 1 branch
BranchTrueFalseTotal
ref $source ? : 571 17 588
66 588 return $sourceref;
67 }
68  
69 36 ▶sub comp_source { ${shift()->comp_source_ref} }
Subroutine comp_source: called CC=1 SCAR=0.0
Pod documented
70  
71 sub object_code
72 35 ▶{
Subroutine object_code: called CC=1 SCAR=0.0
Pod documented
73 35 my $self = shift;
74 35 my %p = validate( @_, { compiler => { isa => 'HTML::Mason::Compiler' } } );
75  
76 35 return $p{compiler}->compile( comp_source => $self->comp_source,
77 name => $self->friendly_name,
78 comp_path => $self->comp_path,
79 comp_class => $self->comp_class,
80 );
81 }
82  
83 33 1;
84  
85 __END__
« lib/HTML/Mason/Escapes.pm ↑ Summary lib/HTML/Mason.pm »