File Coverage

blib/lib/Facebook/InstantArticle/Analytics.pm
Criterion Covered Total %
statement 6 9 66.6
branch 0 4 0.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 8 16 50.0


line stmt bran cond sub pod time code
1             package Facebook::InstantArticle::Analytics;
2 2     2   13 use Moose;
  2         3  
  2         20  
3 2     2   12301 use namespace::autoclean;
  2         4  
  2         19  
4              
5             extends 'Facebook::InstantArticle::BaseElement';
6              
7             has 'source' => (
8             isa => 'Str',
9             is => 'rw',
10             required => 0,
11             default => '',
12             );
13              
14             has 'content' => (
15             isa => 'Str',
16             is => 'rw',
17             required => 0,
18             default => '',
19             );
20              
21             has 'is_valid' => (
22             isa => 'Bool',
23             is => 'ro',
24             lazy => 1,
25             default => sub {
26             my $self = shift;
27              
28             return ( length $self->source || length $self->content ) ? 1 : 0;
29             },
30             );
31              
32             has 'as_xml_gen' => (
33             isa => 'Object',
34             is => 'ro',
35             lazy => 1,
36             builder => '_build_as_xml_gen',
37             );
38              
39             sub _build_as_xml_gen {
40 0     0     my $self = shift;
41              
42 0           my $gen = XML::Generator->new( ':pretty' );
43              
44 0 0         return $gen->figure(
    0          
45             { class => 'op-tracker' },
46             $gen->iframe(
47             ( length $self->source ? { src => $self->source } : undef ),
48             ( length $self->content ? \$self->content : undef ),
49             ),
50             );
51             }
52              
53             1;