File Coverage

blib/lib/Protocol/XMPP/ElementBase.pm
Criterion Covered Total %
statement 9 25 36.0
branch n/a
condition n/a
subroutine 3 9 33.3
pod 6 6 100.0
total 18 40 45.0


line stmt bran cond sub pod time code
1             package Protocol::XMPP::ElementBase;
2              
3 26     26   290509 use strict;
  26         69  
  26         1039  
4 26     26   184 use warnings;
  26         48  
  26         1582  
5 26     26   141 use parent qw{Protocol::XMPP::Base};
  26         46  
  26         193  
6              
7             our $VERSION = '0.007'; ## VERSION
8              
9             =head1 NAME
10              
11             Protocol::XMPP::ElementBase - base class for L XML fragment handling
12              
13             =head1 SYNOPSIS
14              
15             =head1 DESCRIPTION
16              
17             =head1 METHODS
18              
19             =cut
20              
21             sub new {
22 0     0 1   my $class = shift;
23 0           my $self = $class->SUPER::new(@_);
24 0           $self->{data} = '';
25 0           return $self;
26             }
27              
28             =head2 attributes
29              
30             Access the XML element attributes as key-value pairs.
31              
32             =cut
33              
34             sub attributes {
35 0     0 1   my $self = shift;
36             return {
37 0           map { $_->{LocalName} => $_->{Value} } values %{$self->{element}->{Attributes}}
  0            
  0            
38             };
39             }
40              
41             =head2 parent
42              
43             Accessor for the parent object, if available.
44              
45             =cut
46              
47 0     0 1   sub parent { shift->{parent} }
48              
49             =head2 characters
50              
51             Called when new character data is available. Appends to internal buffer.
52              
53             =cut
54              
55             sub characters {
56 0     0 1   my $self = shift;
57 0           my $data = shift;
58 0           $self->{data} .= $data;
59 0           $self;
60             }
61              
62             =head2 end_element
63              
64             Called when an XML element is terminated.
65              
66             =cut
67              
68             sub end_element {
69 0     0 1   my $self = shift;
70 0           $self->debug("Virtual end_element for $_[0]");
71             }
72              
73             =head2 class_from_element
74              
75             Returns a class suitable for handling the given element,
76             if we have one.
77              
78             If we don't have a local handler, returns undef.
79              
80             =cut
81              
82 0     0 1   sub class_from_element { undef }
83              
84             1;
85              
86             __END__